Example #1
0
void CGrenade :: UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code )
{
	edict_t *pentFind;
	edict_t *pentOwner;

	if ( !pevOwner )
		return;

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

	pentOwner = pOwner->edict();

	pentFind = FIND_ENTITY_BY_CLASSNAME( NULL, "grenade" );
	while ( !FNullEnt( pentFind ) )
	{
		CBaseEntity *pEnt = Instance( pentFind );
		if ( 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;
			}
		}
		pentFind = FIND_ENTITY_BY_CLASSNAME( pentFind, "grenade" );
	}
}
Example #2
0
BOOL CGrenade::IsInGaz ( void )
{
	Vector vecPlayer = Center ();

	CBaseEntity *pFind = NULL;
	edict_t *pTrigger = NULL;
	pTrigger = FIND_ENTITY_BY_CLASSNAME( NULL, "trigger_gaz" );

	while ( !FNullEnt ( pTrigger ) )
	{
		pFind = CBaseEntity::Instance ( pTrigger );

		if ( vecPlayer.x > pFind->pev->absmin.x && vecPlayer.x < pFind->pev->absmax.x &&
			 vecPlayer.y > pFind->pev->absmin.y && vecPlayer.y < pFind->pev->absmax.y &&
			 vecPlayer.z > pFind->pev->absmin.z && vecPlayer.z < pFind->pev->absmax.z )		// Player est ds le trigger
		{
			return TRUE;
		}
		else
		{
			pTrigger = FIND_ENTITY_BY_CLASSNAME( pTrigger, "trigger_gaz" );
		}

	}
	return FALSE;
}
Example #3
0
int GetTeam (edict_t *ent)
{
	// SyPB Pro P.1
	// new get team off set, return player true team
	int client = ENTINDEX (ent) - 1, player_team;
	
	 // SyPB Pro P.5
	if (!IsValidPlayer (ent))
	{
		player_team = 0;
		edict_t *entity = null;
		ITERATE_ARRAY (g_entityName, j)
		{
			while (!FNullEnt (entity = FIND_ENTITY_BY_CLASSNAME (entity, g_entityName[j])))
			{
				if (ent == entity)
				{
					player_team = g_entityTeam[j];
					break;
				}
			}
		}
		player_team--;
		
		if (GetGameMod () == 99 && g_DelayTimer > engine->GetTime ())
			player_team = 2;
		
		return player_team;
	}
Example #4
0
void DeactivateBiomass( CBasePlayer *pOwner )
{
	edict_t *pFind; 
	pFind = FIND_ENTITY_BY_CLASSNAME( NULL, "biomass" );

	while ( !FNullEnt( pFind ) )
	{
		CBaseEntity *pEnt = CBaseEntity::Instance( pFind );
		CBiomass *pBioCharge = (CBiomass *)pEnt;

		if ( pBioCharge)
		{
			if ( pBioCharge->pev->owner == pOwner->edict() )
				pBioCharge->Deactivate();
		}
		pFind = FIND_ENTITY_BY_CLASSNAME( pFind, "biomass" );
	}
}
//=========================================================
// DeactivateSatchels - removes all satchels owned by
// the provided player. Should only be used upon death.
//
// Made this global on purpose.
//=========================================================
void DeactivateSatchels(CBasePlayer *pOwner)
{
	edict_t *pFind;

	pFind = FIND_ENTITY_BY_CLASSNAME(NULL, "monster_satchel");
	while (!FNullEnt(pFind))
	{
		CBaseEntity *pEnt = CBaseEntity::Instance(pFind);
		CSatchelCharge *pSatchel = (CSatchelCharge *)pEnt;

		if (pSatchel)
		{
			if (pSatchel->pev->owner == pOwner->edict())
				pSatchel->Deactivate();
		}

		pFind = FIND_ENTITY_BY_CLASSNAME(pFind, "monster_satchel");
	}
}
/*
================
SpectatorImpulseCommand

Called by SpectatorThink if the spectator entered an impulse
================
*/
void CBaseSpectator::SpectatorImpulseCommand(void)
{
	static edict_t	*pGoal		= nullptr;
	edict_t         *pPreviousGoal;
	edict_t         *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 = pGoal;
		pCurrentGoal  = pGoal;
		// Start at the current goal, skip the world, and stop if we looped
		//  back around

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

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

	pev->impulse = 0;
}
Example #7
0
static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params)  /* 4 param */ 
{
	int index = params[1];
	const char *szModel;

	CHECK_ENTITY(index);

	edict_t* pentFind = INDEXENT2(params[4]);
	edict_t* pentOwner = INDEXENT2(index);

	pentFind = FIND_ENTITY_BY_CLASSNAME( pentFind, "grenade" );
	while (!FNullEnt(pentFind)) {
		if (pentFind->v.owner == pentOwner) {
			if (params[3]>0) {
				szModel = (char*)STRING(pentFind->v.model);
				MF_SetAmxString(amx, params[2], szModel, params[3]);
				return ENTINDEX(pentFind);
			}
		}
		pentFind = FIND_ENTITY_BY_CLASSNAME( pentFind, "grenade" );
	}
	return 0;
}
Example #8
0
int CTankBSP :: Classify( void )
{
	// trouve le model

	edict_t *pent = FIND_ENTITY_BY_CLASSNAME ( NULL, "info_tank_model" );

	if ( pent == NULL )
		return CLASS_NONE;

	CTank *pTank = (CTank*) CBaseEntity::Instance(pent);

	// classe selon l'état du tank

	if ( pTank->bTankOn == 1 )
		return CLASS_PLAYER_ALLY;

	return CLASS_NONE;
};
Example #9
0
void CTank :: UseTank ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	edict_t *pentFind;
	CBaseEntity *pFind;

	pentFind = FIND_ENTITY_BY_CLASSNAME( NULL, "info_teleport_destination" );

	if ( pentFind == NULL )
	{
		ALERT ( at_console , "info_tank_model : pas de teleport destination !!!\n" );
		return;
	}

	else
	{
		pFind = CBaseEntity :: Instance ( pentFind );

		Vector vecTeleport = pFind->pev->origin;
		UTIL_SetOrigin( pActivator->pev, vecTeleport );

		m_pPlayer = (CBasePlayer*) pActivator;

		m_pPlayer->m_iDrivingTank	= TRUE;

		m_pPlayer->m_iHideHUD |= HIDEHUD_ALL;


		m_pCam = GetClassPtr( (CTankCam*)NULL );
		UTIL_SetOrigin( m_pCam->pev, vecCamOrigin() );
		m_pCam->pev->angles = TourelleAngle();
		m_pCam->Spawn();
		m_pCam->pev->velocity = ( UpdateCam () - vecCamOrigin() ) /2;
		m_pCam->m_pTankModel = this;


		UpdateCamAngle ( UpdateCam (), 2 );

		m_pCam->SetPlayerTankView ( TRUE );

		SetThink( DriveThink );
		pev->nextthink = gpGlobals->time + 2;
	}
}
Example #10
0
// Find an entity that I'm interested in and precache the sounds he'll need in the sequence.
void CCineMonster::Activate(void)
{
	edict_t *     pentTarget;
	CBaseMonster *pTarget;

	// The entity name could be a target name or a classname
	// Check the targetname
	pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszEntity));
	pTarget    = NULL;

	while(!pTarget && !FNullEnt(pentTarget))
	{
		if(FBitSet(VARS(pentTarget)->flags, FL_MONSTER))
		{
			pTarget = GetMonsterPointer(pentTarget);
		}
		pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
	}

	// If no entity with that targetname, check the classname
	if(!pTarget)
	{
		pentTarget = FIND_ENTITY_BY_CLASSNAME(NULL, STRING(m_iszEntity));
		while(!pTarget && !FNullEnt(pentTarget))
		{
			pTarget    = GetMonsterPointer(pentTarget);
			pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(m_iszEntity));
		}
	}
	// Found a compatible entity
	if(pTarget)
	{
		void *pmodel;
		pmodel = GET_MODEL_PTR(pTarget->edict());
		if(pmodel)
		{
			// Look through the event list for stuff to precache
			SequencePrecache(pmodel, STRING(m_iszIdle));
			SequencePrecache(pmodel, STRING(m_iszPlay));
		}
	}
}
Example #11
0
void CTankBSP :: TouchPlayer ( CBaseEntity *pOther )
{
	if ( !pOther->IsPlayer() )
		return;

// le joueur n active le tank que s il le touche et qu il  est a peu pres au meme niveau que le tank pour eviter que le joueur sortant sur le toit du tank ne l active a nouveau
	if ( pOther->pev->origin.z > pev->origin.z + 48 )
		return;

//	m_pTankModel->UseTank( pOther, pOther, USE_TOGGLE, 0 );

	edict_t *pent = FIND_ENTITY_BY_CLASSNAME ( NULL, "info_tank_model" );

	if ( pent == NULL )
		return;

	CTank *pTank = (CTank*) CBaseEntity::Instance(pent);

	pTank->UseTank( pOther, pOther, USE_TOGGLE, 0 );

}
Example #12
0
int GetTeam (edict_t *ent)
{
	// SyPB Pro P.1
	// new get team off set, return player true team
	int client = ENTINDEX (ent) - 1, player_team;
	
	 // SyPB Pro P.5
	if (!IsValidPlayer (ent))
	{
		player_team = 0;
		edict_t *entity = null;
		ITERATE_ARRAY (g_entityName, j)
		{
			while (!FNullEnt (entity = FIND_ENTITY_BY_CLASSNAME (entity, g_entityName[j])))
			{
				if (ent == entity)
				{
					player_team = g_entityTeam[j];
					break;
				}
			}
		}

		// SyPB Pro P.40 - AMXX API
		ITERATE_ARRAY(g_entityIdAPI, j)
		{
			if (ent == INDEXENT(g_entityIdAPI[j]))
			{
				player_team = g_entityTeamAPI[j];
				break;
			}
		}

		player_team--;

		return player_team;
	}
Example #13
0
// SyPB Pro P.29 - new Look UP Enemy
bool Bot::LookupEnemy(void)
{
	m_visibility = 0;
	m_enemyOrigin = nullvec;

	if (m_blindTime > engine->GetTime() || sypb_noshots.GetBool())
		return false;

	if (!FNullEnt(m_lastEnemy))
	{
		if (IsNotAttackLab(m_lastEnemy) || !IsAlive(m_lastEnemy) || (GetTeam(m_lastEnemy) == GetTeam(GetEntity())))
		{
			m_lastEnemy = null;
			m_lastEnemyOrigin = nullvec;
		}
	}

	if (!FNullEnt(m_lastVictim))
	{
		if (!IsAlive(m_lastVictim) || (GetTeam(m_lastVictim) == GetTeam(GetEntity())))
			m_lastVictim = null;
	}

	m_states &= ~STATE_SUSPECTENEMY;

	int team = GetTeam(GetEntity()), i;
	edict_t *entity = null, *targetEntity = null;
	float enemy_distance = 9999.0f;

	// SyPB Pro P.30 - AMXX API
	if (m_blockCheckEnemyTime > engine->GetTime())
	{
		if (!FNullEnt(m_moveTargetEntityAPI))
		{
			if (GetTeam(GetEntity()) != GetTeam(m_moveTargetEntityAPI) && IsAlive(m_moveTargetEntityAPI))
				SetMoveTarget(m_moveTargetEntityAPI);
			else
			{
				// SyPB Pro P.32 - API Fixed
				SetMoveTarget(null);

				m_moveTargetEntityAPI = null;
			}
		}
		else if (!FNullEnt(m_enemyAPI))
		{
			if (GetTeam(GetEntity()) != GetTeam(m_enemyAPI) && IsAlive(m_enemyAPI))
			{
				m_targetEntity = null;
				m_enemy = m_enemyAPI;
				m_lastEnemy = m_enemy;
				m_lastEnemyOrigin = GetEntityOrigin(m_enemy);
				m_enemyReachableTimer = 0.0f;
				m_seeEnemyTime = engine->GetTime();

				if (!IsEnemyViewable(m_enemy, 1))
					m_enemyOrigin = GetEntityOrigin(m_enemy);

				return true;
			}
			else
				m_enemyAPI = null;
		}
		return false;
	}
	m_enemyAPI = null;
	m_moveTargetEntityAPI = null;

	if (!FNullEnt(m_enemy))
	{
		if (GetTeam(GetEntity()) == GetTeam(m_enemy) || IsNotAttackLab(m_enemy) || !IsAlive(m_enemy))
			return false;

		if (m_enemyUpdateTime > engine->GetTime() && !(m_states & STATE_SUSPECTENEMY))
		{
			m_aimFlags |= AIM_ENEMY;
			return true;
		}

		if (IsEnemyViewable(m_enemy, 1))
		{
			targetEntity = m_enemy;
			enemy_distance = GetEntityDistance(m_enemy);
		}
	}
	else if (!FNullEnt(m_moveTargetEntity))
	{
		if (GetTeam(GetEntity()) == GetTeam(m_moveTargetEntity) || !IsAlive(m_moveTargetEntity))
		{
			SetMoveTarget(null);
			return false;
		}

		targetEntity = m_moveTargetEntity;
		m_moveTargetOrigin = GetEntityOrigin(m_moveTargetEntity);
		enemy_distance = GetEntityDistance(m_moveTargetEntity);
	}
	
	// SyPB Pro P.34 - Zombie mode
	if (IsZombieBot(GetEntity()))
	{
		if (!FNullEnt(m_moveTargetEntity))
		{
			if (m_enemyUpdateTime > engine->GetTime())
				return false;
		}

		if (FNullEnt (m_enemy))
			m_enemyUpdateTime = engine->GetTime() + 0.15f;
	}


	for (i = 1; i <= engine->GetMaxClients(); i++)
	{
		entity = INDEXENT(i);

		if (FNullEnt(entity) || !IsAlive(entity) || GetTeam(entity) == team || entity == GetEntity())
			continue;

		if (IsBehindSmokeClouds(entity) && m_blindRecognizeTime < engine->GetTime())
			m_blindRecognizeTime = engine->GetTime() + engine->RandomFloat(2.0, 3.0f);

		if (m_blindRecognizeTime >= engine->GetTime())
			continue;

		float distance = GetEntityDistance(entity);
		if (distance >= enemy_distance)
			continue;

		if (IsEnemyProtectedByShield(entity))
			continue;

		if (IsEnemyViewable(entity))
		{
			enemy_distance = distance;
			targetEntity = entity;

			if ((g_mapType & MAP_AS) && *(INFOKEY_VALUE(GET_INFOKEYBUFFER(entity), "model")) == 'v')
				break;
		}
	}

	ITERATE_ARRAY(g_entityName, j)
	{
		if (g_entityAction[j] != 1 || (GetTeam(GetEntity()) == (g_entityTeam[j] - 1) && g_entityTeam[j] != 0))
			continue;

		while (!FNullEnt(entity = FIND_ENTITY_BY_CLASSNAME(entity, g_entityName[j])))
		{
			if (FNullEnt(entity) || entity == m_enemy)
				continue;

			float distance = GetEntityDistance(entity);
			if (distance >= enemy_distance)
				continue;

			if (IsBehindSmokeClouds(entity) && m_blindRecognizeTime < engine->GetTime())
				m_blindRecognizeTime = engine->GetTime() + engine->RandomFloat(2.0, 3.0f);

			// SyPB Pro P.30 - NPC Fixed
			if (IsEnemyViewable(entity))
			{
				enemy_distance = distance;
				targetEntity = entity;
			}
		}
	}


	if (!FNullEnt(targetEntity))  // Last Checking
	{
		enemy_distance = GetEntityDistance(targetEntity);
		if (GetTeam(targetEntity) == team || !IsEnemyViewable(targetEntity, 1))
			targetEntity = null;
	}

	if (!FNullEnt(m_enemy) && IsZombieBot(GetEntity()))
	{
		if (FNullEnt(targetEntity))  // Has not new enemy, and cannot see old enemy
		{
			g_botsCanPause = false;

			// SyPB Pro P.32 - Zombie Ai
			int botSrcIndex = g_waypoint->FindNearest(pev->origin);
			int targetSrcIndex = g_waypoint->FindNearest(GetEntityOrigin (m_enemy));
			int botStartIndex = *(g_waypoint->m_pathMatrix + (botSrcIndex * g_numWaypoints) + targetSrcIndex);
			if (!(botStartIndex < 0))
				ChangeWptIndex(botStartIndex);

			RemoveCertainTask(TASK_MOVETOTARGET);
			SetMoveTarget(m_enemy);
			return false;
		}
		// SyPB Pro P.30 - Zombie Ai
		else if (targetEntity != m_enemy)
		{
			float distance = GetEntityDistance(m_enemy);
			if (enemy_distance + 50.0f >= distance)
			{
				targetEntity = m_enemy;
				enemy_distance = distance;
			}
		}
	}

	if (!FNullEnt(targetEntity))
	{
		// SyPB Pro P.34 - Zombie Ai
		if (IsZombieBot(GetEntity()))
		{
			// SyPB Pro P.36 - Zombie Ai
			float distance = GetEntityDistance(targetEntity);

			enemy_distance = (GetEntityOrigin (targetEntity) - pev->origin).GetLength();
			bool moveTotarget = false;
			if (enemy_distance >= 150.0f)
			{
				moveTotarget = true;

				if (targetEntity == m_moveTargetEntity)
				{
					if (m_navNode == null || (m_navNode != null && m_navNode->next == null))
					{
						moveTotarget = false;

						// SyPB Pro P.37 - Zombie Ai
						m_enemyUpdateTime = engine->GetTime() + 4.0f;
					}
				}
			}
			else if (enemy_distance >= 80.0f && distance >= (enemy_distance * 2))
				moveTotarget = true;
			//else if (m_navNode != null && enemy_distance > 20.0f && distance >= 30.0f)//&& enemy_distance > 40.0f)
			else if (m_navNode != null && enemy_distance >= 20.0f)// && distance >= 30.0f)
			{
				PathNode *navid = &m_navNode[0];
				Path *path;

				while (navid != null)
				{
					path = g_waypoint->GetPath(navid->index);
					navid = navid->next;

					if (navid != null)
					{
						if (path->connectionFlags[navid->index] & PATHFLAG_JUMP)
						{
							moveTotarget = true;
							navid = null;
						}
					}
				}
			}

			if (moveTotarget)
			{
				// SyPB Pro P.35 - Fixed
				if (enemy_distance <= 80.0f)
				//if (moveTotarget <= 80.0f)
					pev->button |= IN_ATTACK;

				if (targetEntity != m_moveTargetEntity)
				{
					g_botsCanPause = false;

					// SyPB Pro P.32 - Zombie Ai
					int botSrcIndex = g_waypoint->FindNearest(pev->origin);
					int targetSrcIndex = g_waypoint->FindNearest(GetEntityOrigin (targetEntity));
					int botStartIndex = *(g_waypoint->m_pathMatrix + (botSrcIndex * g_numWaypoints) + targetSrcIndex);
					if (!(botStartIndex < 0))
						ChangeWptIndex(botStartIndex);

					SetMoveTarget(targetEntity);
				}

				return false;
			}

			// SyPB Pro P.37 - Zombie Ai
			if (m_enemyUpdateTime < engine->GetTime() + 3.0f)
				m_enemyUpdateTime = engine->GetTime() + 2.5f;
		}

		g_botsCanPause = true;
		m_aimFlags |= AIM_ENEMY;

		if (targetEntity == m_enemy)
		{
			m_seeEnemyTime = engine->GetTime();

			m_actualReactionTime = 0.0f;
			m_lastEnemy = targetEntity;
			m_lastEnemyOrigin = GetEntityOrigin(targetEntity);

			return true;
		}

		if (m_seeEnemyTime + 3.0f < engine->GetTime() && (pev->weapons & (1 << WEAPON_C4) || HasHostage() || !FNullEnt(m_targetEntity)))
			RadioMessage(Radio_EnemySpotted);

		m_targetEntity = null;

		if (engine->RandomInt(0, 100) < m_skill)
			m_enemySurpriseTime = engine->GetTime() + (m_actualReactionTime / 3);
		else
			m_enemySurpriseTime = engine->GetTime() + m_actualReactionTime;

		m_actualReactionTime = 0.0f;

		m_enemy = targetEntity;
		m_lastEnemy = m_enemy;
		m_lastEnemyOrigin = GetEntityOrigin(m_enemy);
		m_enemyReachableTimer = 0.0f;
		m_seeEnemyTime = engine->GetTime();


		if (!IsZombieBot(GetEntity()))
			m_enemyUpdateTime = engine->GetTime() + 0.6f;
		//m_enemyUpdateTime = (IsZombieBot(GetEntity()) ? engine->GetTime() + 2.5f : engine->GetTime() + 0.6f);

		return true;
	}

	if ((m_aimFlags <= AIM_PREDICTENEMY && m_seeEnemyTime + 4.0f < engine->GetTime() && !(m_states & (STATE_SEEINGENEMY | STATE_HEARENEMY)) && FNullEnt(m_lastEnemy) && FNullEnt(m_enemy) && GetCurrentTask()->taskID != TASK_DESTROYBREAKABLE && GetCurrentTask()->taskID != TASK_PLANTBOMB && GetCurrentTask()->taskID != TASK_DEFUSEBOMB) || g_roundEnded)
	{
		if (!m_reloadState)
			m_reloadState = RSTATE_PRIMARY;
	}

	if ((UsesSniper() || UsesZoomableRifle()) && m_zoomCheckTime + 1.0f < engine->GetTime())
	{
		if (pev->fov < 90)
			pev->button |= IN_ATTACK2;
		else
			m_zoomCheckTime = 0.0f;
	}

	return false;
}
Example #14
0
int CTank::Restore( CRestore &restore )		// s execute lors du chargement rapide
{
	if ( !CBaseMonster::Restore(restore) )
		return 0;

	int status = restore.ReadFields( "CTank", this, m_SaveData, ARRAYSIZE(m_SaveData) );

	//-----------------------

	ALERT ( at_console,"TANK RESTORE -----------------\n" );

	// restoration de la camera
	bSetView = 1;


	// restoration du tank

	CBaseEntity *pFind = UTIL_FindEntityByClassname( NULL, "info_tank_model" );

	while ( pFind != NULL && pFind == this )
		pFind = UTIL_FindEntityByClassname( pFind, "info_tank_model" );


	// chargement
	if ( pFind == NULL )
	{
		ALERT ( at_console, "TANK RESTORE : il n'y a qu'un tankmodel : simple chargement\n" );
		return status;
	}

	// changement de niveau
	ALERT ( at_console, "TANK RESTORE : autre tankmodel : changement de niveau\n" );

	CTank *pModelFound = (CTank*)pFind;

	m_pTankBSP = pModelFound->m_pTankBSP;					// changement de tankbsp
	m_pTankBSP->m_pTankModel = this;

	pModelFound->SetThink ( SUB_Remove );					// destruction du tankmodel inutile
	pModelFound->pev->nextthink = gpGlobals->time + 0.1;
	pModelFound->pev->rendermode = kRenderTransTexture;
	pModelFound->pev->renderamt = 0;

	m_pTankBSP->pev->angles = pev->angles;
	m_pTankBSP->pev->origin = pev->origin;


	// tite boite

	edict_t *pentTrouve;
	CBaseEntity *pTrouve;

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

	pentTrouve = FIND_ENTITY_BY_CLASSNAME( NULL, "info_teleport_destination" );

	if ( pentTrouve == NULL )
	{
		ALERT ( at_console , "info_tank_model : pas de teleport destination !!!\n" );
		return status;
	}

	else
	{
		pTrouve = CBaseEntity :: Instance ( pentTrouve );

		Vector vecTeleport = pTrouve->pev->origin;
		UTIL_SetOrigin( pPlayer->pev, vecTeleport );
	}


	
	return status;
}
Example #15
0
/* <18b0fb> ../cstrike/dlls/training_gamerules.cpp:202 */
void CHalfLifeTraining::__MAKE_VHOOK(CheckWinConditions)()
{
	CBaseEntity *pHostage = NULL;

	if (m_bBombDefused)
	{
		CGrenade *pBomb = NULL;

		while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade")) != NULL)
		{
			if (!pBomb->m_bIsC4 || !pBomb->m_bJustBlew)
				continue;

			pBomb->m_bJustBlew = false;
			m_bBombDefused = false;
			FireTargets(STRING(pBomb->pev->target), CBaseEntity::Instance(pBomb->pev->owner), CBaseEntity::Instance(pBomb->pev->owner), USE_TOGGLE, 0);
			break;
		}
	}
	else if (m_bTargetBombed)
	{
		CGrenade *pBomb = NULL;

		while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade")) != NULL)
		{
			if (!pBomb->m_bIsC4 || !pBomb->m_bJustBlew)
				continue;

			if (FStringNull(pBomb->pev->noise1))
				continue;

			pBomb->m_bJustBlew = false;
			m_bTargetBombed = false;
			FireTargets(STRING(pBomb->pev->noise1), CBaseEntity::Instance(pBomb->pev->owner), CBaseEntity::Instance(pBomb->pev->owner), USE_TOGGLE, 0);
			break;
		}
	}

	pHostage = CBaseEntity::Instance(FIND_ENTITY_BY_CLASSNAME(NULL, "hostage_entity"));

	while (pHostage != NULL)
	{
		if (pHostage->pev->deadflag != DEAD_RESPAWNABLE || !FStringNull(pHostage->pev->noise1))
			continue;

		UTIL_SetSize(pHostage->pev, Vector(-16, -16, 0), Vector(16, 16, 72));

		CBaseEntity *pRescueArea;
		CBaseEntity *pFirstRescueArea;

		pFirstRescueArea = CBaseEntity::Instance(FIND_ENTITY_BY_CLASSNAME(NULL, "func_hostage_rescue"));
		pRescueArea = pFirstRescueArea;

		if (pFirstRescueArea != NULL)
		{
			while (pRescueArea != pFirstRescueArea)
			{
				if (!pRescueArea->Intersects(pHostage))
					break;

				pRescueArea = UTIL_FindEntityByClassname(pRescueArea, "func_hostage_rescue");

				if (!pRescueArea)
					break;
			}

			if (pRescueArea != NULL)
			{
				pHostage->pev->noise1 = 1;
				FireTargets(STRING(pRescueArea->pev->target), NULL, NULL, USE_TOGGLE, 0);
			}
		}

		pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity");
	}
}
Example #16
0
// Use CMD_ARGV,  CMD_ARGV, and CMD_ARGC to get pointers the character string command.
void ClientCommand( edict_t *pEntity )
{
	const char *pcmd = CMD_ARGV(0);
	const char *pstr;

	// Is the client spawned yet?
	if ( !pEntity->pvPrivateData )
		return;

	entvars_t *pev = &pEntity->v;

	if ( FStrEq(pcmd, "say" ) )
	{
		Host_Say( pEntity, 0 );
	}
	else if ( FStrEq(pcmd, "say_team" ) )
	{
		Host_Say( pEntity, 1 );
	}
	else if ( FStrEq(pcmd, "give" ) )
	{
		if ( g_flWeaponCheat != 0.0)
		{
			int iszItem = ALLOC_STRING( CMD_ARGV(1) );	// Make a copy of the classname
			GetClassPtr((CBasePlayer *)pev)->GiveNamedItem( STRING(iszItem) );
		}
	}

	else if ( FStrEq(pcmd, "drop" ) )
	{
		// player is dropping an item. 
		GetClassPtr((CBasePlayer *)pev)->DropPlayerItem((char *)CMD_ARGV(1));
	}
	else if ( FStrEq(pcmd, "fov" ) )
	{
		if ( g_flWeaponCheat && CMD_ARGC() > 1)
		{
			GetClassPtr((CBasePlayer *)pev)->m_iFOV = atoi( CMD_ARGV(1) );
		}
		else
		{
			CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr((CBasePlayer *)pev)->m_iFOV ) );
		}
	}
	else if ( FStrEq(pcmd, "use" ) )
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem((char *)CMD_ARGV(1));
	}
	else if (((pstr = strstr(pcmd, "weapon_")) != NULL)  && (pstr == pcmd))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectItem(pcmd);
	}
	else if (FStrEq(pcmd, "lastinv" ))
	{
		GetClassPtr((CBasePlayer *)pev)->SelectLastItem();
	}
	//modif de Julien
	else if (FStrEq(pcmd, "test" ))
	{
		ALERT ( at_console , "testmode ON\n" );
		g_testmode = 1;

		int i = 0;
		while ( i < 5 )
		{
			GetClassPtr((CBasePlayer *)pev)->CheatImpulseCommands( 101 );
			i++;
		}
	}

	//modif de Julien
	else if (FStrEq(pcmd, "testmode" ))
	{
		ALERT ( at_console , "testmode ON\n" );
		g_testmode = 1;
	}



	// SCHED_DIE
	//modif de Julien
	else if (FStrEq(pcmd, "flybee" ))
	{

/*		CBaseMonster *pFlybee = ( CBaseMonster *) UTIL_FindEntityByClassname ( NULL, "monster_flybee" );

		if ( pFlybee != NULL )
		{
			pFlybee->GetScheduleOfType ( SCHED_DIE );
		}*/

		CBaseEntity *pMe = CBaseEntity::Instance ( pEntity );


		CBaseEntity *pE = FindEntityForward( pMe );

		if ( pE )
		{
			if ( pE->pev->takedamage )
				pE->TakeDamage ( pev, pev, pE->pev->health, DMG_GENERIC );
		}
	}

	//modif de Julien
	else if (FStrEq(pcmd, "ordimenu" ))
	{
		if ( atoi(CMD_ARGV(1)) == 2 )
		{
			EMIT_SOUND( ENT(pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM );

			//désactive les caméras
			
			edict_t* pentCherche = NULL;

			for ( int i = 0 ; i<15 ; i++ )
			{
				pentCherche = FIND_ENTITY_BY_CLASSNAME ( pentCherche, "monster_camera" );

				if (!FNullEnt(pentCherche))
				{
					CBaseEntity *pTarget = CBaseEntity::Instance(pentCherche);
					pTarget->Use( CBaseEntity::Instance(pEntity), CBaseEntity::Instance(pEntity), USE_ON, 1 );
					//la valeur 1 désactive la camera, 0 la déclenche
				}
			}

			// détruit certains triggers

			pentCherche = NULL;

			for ( int j = 0 ; j<5 ; j++ )
			{
				pentCherche = FIND_ENTITY_BY_TARGETNAME ( pentCherche, "security" );

				if (!FNullEnt(pentCherche))
					UTIL_Remove( CBaseEntity::Instance(pentCherche) );
			}
			for ( int k = 0 ; k<5 ; k++ )
			{
				pentCherche = FIND_ENTITY_BY_TARGETNAME ( pentCherche, "security_2" );

				if (!FNullEnt(pentCherche))
					UTIL_Remove( CBaseEntity::Instance(pentCherche) );
			}

			for ( int l = 0 ; l<5 ; l++ )
			{
				pentCherche = FIND_ENTITY_BY_TARGETNAME ( pentCherche, "security_3" );

				if (!FNullEnt(pentCherche))
					UTIL_Remove( CBaseEntity::Instance(pentCherche) );
			}

		}

		else if ( atoi(CMD_ARGV(1)) == 1 )
			EMIT_SOUND( ENT(pev), CHAN_ITEM, "sentences/blip.wav", 1, ATTN_NORM );
	}

	//modif de Julien
	else if (FStrEq(pcmd, "ordicontrol" ))
	{
		CBaseEntity *pEnt = UTIL_FindEntityByClassname ( NULL, "func_conveyorcontrol" );

		if ( pEnt != NULL )
		{
			pEnt->Use ( GetClassPtr((CBasePlayer *)pev), GetClassPtr((CBasePlayer *)pev), USE_OFF, atoi(CMD_ARGV(1)) );
		}

	}

	else if (FStrEq(pcmd, "keypad" ))
	{
		if ( atoi(CMD_ARGV(1)) == 0 )
		{
			EMIT_SOUND( ENT(pev), CHAN_ITEM, "buttons/button10.wav", 1, ATTN_NORM );
			return;
		}

		CBaseEntity *pEntity = UTIL_FindEntityByClassname ( NULL, "func_keypad" );

		while ( pEntity != NULL )
		{
			if ( ENTINDEX(pEntity->edict()) == atoi(CMD_ARGV(1)) )
			{
				FireTargets ( STRING(pEntity->pev->target), pEntity, GetClassPtr((CBasePlayer *)pev), USE_ON, 0 );
				break;
			}

			pEntity = UTIL_FindEntityByClassname ( pEntity, "func_keypad" );
		}

		EMIT_SOUND( ENT(pev), CHAN_ITEM, "buttons/blip2.wav", 1, ATTN_NORM );

	}

	else if (FStrEq(pcmd, "medkit" ))
	{
		GetClassPtr((CBasePlayer *)pev)->UseMedkit();
	}

	else if (FStrEq(pcmd, "battery" ))
	{
		GetClassPtr((CBasePlayer *)pev)->UseBattery(0);
	}

	else if (FStrEq(pcmd, "soin" ))
	{
		int commande = atoi(CMD_ARGV(1));
		GetClassPtr((CBasePlayer *)pev)->UseBattery(commande);
	}


	else if ( g_pGameRules->ClientCommand( GetClassPtr((CBasePlayer *)pev), pcmd ) )
	{
		// MenuSelect returns true only if the command is properly handled,  so don't print a warning
	}
	else
	{
		// tell the user they entered an unknown command
		ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", pcmd ) );
	}
}
Example #17
0
// UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution.
void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType )
{
	float		flRndSound;// sound randomizer

	pev->model = iStringNull;//invisible
	pev->solid = SOLID_NOT;// intangible

	pev->takedamage = DAMAGE_NO;

	// Pull out of the wall a bit
	if ( pTrace->flFraction != 1.0 )
	{
		pev->origin = pTrace->vecEndPos + (pTrace->vecPlaneNormal * (pev->dmg - 24) * 0.6);
	}

	int iContents = UTIL_PointContents ( pev->origin );

	
	MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
		WRITE_BYTE( TE_EXPLOSION );		// This makes a dynamic light and the explosion sprites/sound
		WRITE_COORD( pev->origin.x );	// Send to PAS because of the sound
		WRITE_COORD( pev->origin.y );
		WRITE_COORD( pev->origin.z );
		if (iContents != CONTENTS_WATER)
		{
			WRITE_SHORT( g_sModelIndexFireball );
		}
		else
		{
			WRITE_SHORT( g_sModelIndexWExplosion );
		}
		WRITE_BYTE( (pev->dmg - 50) * .60  ); // scale * 10
		WRITE_BYTE( 15  ); // framerate
		WRITE_BYTE( TE_EXPLFLAG_NONE );
	MESSAGE_END();


	CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 );
	entvars_t *pevOwner;
	if ( pev->owner )
		pevOwner = VARS( pev->owner );
	else
		pevOwner = NULL;

	pev->owner = NULL; // can't traceline attack owner if this is set

	RadiusDamage ( pev, pevOwner, pev->dmg, CLASS_NONE, bitsDamageType );

	if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 )
	{
		UTIL_DecalTrace( pTrace, DECAL_SCORCH1 );
	}
	else
	{
		UTIL_DecalTrace( pTrace, DECAL_SCORCH2 );
	}

	flRndSound = RANDOM_FLOAT( 0 , 1 );

	switch ( RANDOM_LONG( 0, 2 ) )
	{
		case 0:	EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris1.wav", 0.55, ATTN_NORM);	break;
		case 1:	EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris2.wav", 0.55, ATTN_NORM);	break;
		case 2:	EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/debris3.wav", 0.55, ATTN_NORM);	break;
	}

	//modif de Julien

	UTIL_ScreenShake( pev->origin, 100, 85, 1.0, 500 );

	//====================

	pev->effects |= EF_NODRAW;
	SetThink( Smoke );
	pev->velocity = g_vecZero;
	pev->nextthink = gpGlobals->time + 0.3;

	if (iContents != CONTENTS_WATER)
	{
		int sparkCount = RANDOM_LONG(0,3);
		for ( int i = 0; i < sparkCount; i++ )
			Create( "spark_shower", pev->origin, pTrace->vecPlaneNormal, NULL );
	}

	if ( IsInGaz () )
	{
		edict_t *pFind = FIND_ENTITY_BY_CLASSNAME( NULL, "player" );
		CBaseEntity *pPlayer = CBaseEntity::Instance ( pFind );
		pPlayer->m_bFireInGaz = TRUE;
	}
}
Example #18
0
//=========================================================
// Start task - selects the correct activity and performs
// any necessary calculations to start the next task on the
// schedule. 
//=========================================================
void CBaseMonster :: StartTask ( Task_t *pTask )
{
	switch ( pTask->iTask )
	{
	case TASK_TURN_RIGHT:
		{
			float flCurrentYaw;
			
			flCurrentYaw = UTIL_AngleMod( pev->angles.y );
			pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw - pTask->flData );
			SetTurnActivity();
			break;
		}
	case TASK_TURN_LEFT:
		{
			float flCurrentYaw;
			
			flCurrentYaw = UTIL_AngleMod( pev->angles.y );
			pev->ideal_yaw = UTIL_AngleMod( flCurrentYaw + pTask->flData );
			SetTurnActivity();
			break;
		}
	case TASK_REMEMBER:
		{
			Remember ( (int)pTask->flData );
			TaskComplete();
			break;
		}
	case TASK_FORGET:
		{
			Forget ( (int)pTask->flData );
			TaskComplete();
			break;
		}
	case TASK_FIND_HINTNODE:
		{
			m_iHintNode = FindHintNode();

			if ( m_iHintNode != NO_NODE )
			{
				TaskComplete();
			}
			else
			{
				TaskFail();
			}
			break;
		}
	case TASK_STORE_LASTPOSITION:
		{
			m_vecLastPosition = pev->origin;
			TaskComplete();
			break;
		}
	case TASK_CLEAR_LASTPOSITION:
		{
			m_vecLastPosition = g_vecZero;
			TaskComplete();
			break;
		}
	case TASK_CLEAR_HINTNODE:
		{
			m_iHintNode = NO_NODE;
			TaskComplete();
			break;
		}
	case TASK_STOP_MOVING:
		{
			if ( m_IdealActivity == m_movementActivity )
			{
				m_IdealActivity = GetStoppedActivity();
			}

			RouteClear();
			TaskComplete();
			break;
		}
	case TASK_PLAY_SEQUENCE_FACE_ENEMY:
	case TASK_PLAY_SEQUENCE_FACE_TARGET:
	case TASK_PLAY_SEQUENCE:
		{
			m_IdealActivity = ( Activity )( int )pTask->flData;
			break;
		}
	case TASK_PLAY_ACTIVE_IDLE:
		{
			// monsters verify that they have a sequence for the node's activity BEFORE
			// moving towards the node, so it's ok to just set the activity without checking here.
			m_IdealActivity = ( Activity )WorldGraph.m_pNodes[ m_iHintNode ].m_sHintActivity;
			break;
		}
	case TASK_SET_SCHEDULE:
		{
			Schedule_t *pNewSchedule;

			pNewSchedule = GetScheduleOfType( (int)pTask->flData );
			
			if ( pNewSchedule )
			{
				ChangeSchedule( pNewSchedule );
			}
			else
			{
				TaskFail();
			}

			break;
		}
	case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY:
		{
			if ( m_hEnemy == NULL )
			{
				TaskFail();
				return;
			}

			if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, pTask->flData ) )
			{
				// try for cover farther than the FLData from the schedule.
				TaskComplete();
			}
			else
			{
				// no coverwhatsoever.
				TaskFail();
			}
			break;
		}
	case TASK_FIND_FAR_NODE_COVER_FROM_ENEMY:
		{
			if ( m_hEnemy == NULL )
			{
				TaskFail();
				return;
			}

			if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, pTask->flData, CoverRadius() ) )
			{
				// try for cover farther than the FLData from the schedule.
				TaskComplete();
			}
			else
			{
				// no coverwhatsoever.
				TaskFail();
			}
			break;
		}
	case TASK_FIND_NODE_COVER_FROM_ENEMY:
		{
			if ( m_hEnemy == NULL )
			{
				TaskFail();
				return;
			}

			if ( FindCover( m_hEnemy->pev->origin, m_hEnemy->pev->view_ofs, 0, CoverRadius() ) )
			{
				// try for cover farther than the FLData from the schedule.
				TaskComplete();
			}
			else
			{
				// no coverwhatsoever.
				TaskFail();
			}
			break;
		}
	case TASK_FIND_COVER_FROM_ENEMY:
		{
			entvars_t *pevCover;

			if ( m_hEnemy == NULL )
			{
				// Find cover from self if no enemy available
				pevCover = pev;
//				TaskFail();
//				return;
			}
			else
				pevCover = m_hEnemy->pev;

			if ( FindLateralCover( pevCover->origin, pevCover->view_ofs ) )
			{
				// try lateral first
				m_flMoveWaitFinished = gpGlobals->time + pTask->flData;
				TaskComplete();
			}
			else if ( FindCover( pevCover->origin, pevCover->view_ofs, 0, CoverRadius() ) )
			{
				// then try for plain ole cover
				m_flMoveWaitFinished = gpGlobals->time + pTask->flData;
				TaskComplete();
			}
			else
			{
				// no coverwhatsoever.
				TaskFail();
			}
			break;
		}
	case TASK_FIND_COVER_FROM_ORIGIN:
		{
			if ( FindCover( pev->origin, pev->view_ofs, 0, CoverRadius() ) )
			{
				// then try for plain ole cover
				m_flMoveWaitFinished = gpGlobals->time + pTask->flData;
				TaskComplete();
			}
			else
			{
				// no cover!
				TaskFail();
			}
		}
		break;
	case TASK_FIND_COVER_FROM_BEST_SOUND:
		{
			CSound *pBestSound;

			pBestSound = PBestSound();

			ASSERT( pBestSound != NULL );
			/*
			if ( pBestSound && FindLateralCover( pBestSound->m_vecOrigin, g_vecZero ) )
			{
				// try lateral first
				m_flMoveWaitFinished = gpGlobals->time + pTask->flData;
				TaskComplete();
			}
			*/

			if ( pBestSound && FindCover( pBestSound->m_vecOrigin, g_vecZero, pBestSound->m_iVolume, CoverRadius() ) )
			{
				// then try for plain ole cover
				m_flMoveWaitFinished = gpGlobals->time + pTask->flData;
				TaskComplete();
			}
			else
			{
				// no coverwhatsoever. or no sound in list
				TaskFail();
			}
			break;
		}
	case TASK_FACE_HINTNODE:
		{
			pev->ideal_yaw = WorldGraph.m_pNodes[ m_iHintNode ].m_flHintYaw;
			SetTurnActivity();
			break;
		}
	
	case TASK_FACE_LASTPOSITION:
		MakeIdealYaw ( m_vecLastPosition );
		SetTurnActivity(); 
		break;

	case TASK_FACE_TARGET:
		if ( m_hTargetEnt != NULL )
		{
			MakeIdealYaw ( m_hTargetEnt->pev->origin );
			SetTurnActivity(); 
		}
		else
			TaskFail();
		break;
	case TASK_FACE_ENEMY:
		{
			MakeIdealYaw ( m_vecEnemyLKP );
			SetTurnActivity(); 
			break;
		}
	case TASK_FACE_IDEAL:
		{
			SetTurnActivity();
			break;
		}
	case TASK_FACE_ROUTE:
		{
			if (FRouteClear())
			{
				ALERT(at_aiconsole, "No route to face!\n");
				TaskFail();
			}
			else
			{
				MakeIdealYaw(m_Route[m_iRouteIndex].vecLocation);
				SetTurnActivity();
			}
			break;
		}
	case TASK_WAIT_PVS:
	case TASK_WAIT_INDEFINITE:
		{
			// don't do anything.
			break;
		}
	case TASK_WAIT:
	case TASK_WAIT_FACE_ENEMY:
		{// set a future time that tells us when the wait is over.
			m_flWaitFinished = gpGlobals->time + pTask->flData;	
			break;
		}
	case TASK_WAIT_RANDOM:
		{// set a future time that tells us when the wait is over.
			m_flWaitFinished = gpGlobals->time + RANDOM_FLOAT( 0.1, pTask->flData );
			break;
		}
	case TASK_MOVE_TO_TARGET_RANGE:
		{
			if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 )
				TaskComplete();
			else
			{
				m_vecMoveGoal = m_hTargetEnt->pev->origin;
				if ( !MoveToTarget( ACT_WALK, 2 ) )
					TaskFail();
			}
			break;
		}
	case TASK_RUN_TO_TARGET:
	case TASK_WALK_TO_TARGET:
		{
			Activity newActivity;

			if ( (m_hTargetEnt->pev->origin - pev->origin).Length() < 1 )
				TaskComplete();
			else
			{
				if ( pTask->iTask == TASK_WALK_TO_TARGET )
					newActivity = ACT_WALK;
				else
					newActivity = ACT_RUN;
				// This monster can't do this!
				if ( LookupActivity( newActivity ) == ACTIVITY_NOT_AVAILABLE )
					TaskComplete();
				else 
				{
					if ( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) )
					{
						TaskFail();
						ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING(pev->classname) );
						RouteClear();
					}
				}
			}
			TaskComplete();
			break;
		}
	case TASK_CLEAR_MOVE_WAIT:
		{
			m_flMoveWaitFinished = gpGlobals->time;
			TaskComplete();
			break;
		}
	case TASK_MELEE_ATTACK1_NOTURN:
	case TASK_MELEE_ATTACK1:
		{
			m_IdealActivity = ACT_MELEE_ATTACK1;
			break;
		}
	case TASK_MELEE_ATTACK2_NOTURN:
	case TASK_MELEE_ATTACK2:
		{
			m_IdealActivity = ACT_MELEE_ATTACK2;
			break;
		}
	case TASK_RANGE_ATTACK1_NOTURN:
	case TASK_RANGE_ATTACK1:
		{
			m_IdealActivity = ACT_RANGE_ATTACK1;
			break;
		}
	case TASK_RANGE_ATTACK2_NOTURN:
	case TASK_RANGE_ATTACK2:
		{
			m_IdealActivity = ACT_RANGE_ATTACK2;
			break;
		}
	case TASK_RELOAD_NOTURN:
	case TASK_RELOAD:
		{
			m_IdealActivity = ACT_RELOAD;
			break;
		}
	case TASK_SPECIAL_ATTACK1:
		{
			m_IdealActivity = ACT_SPECIAL_ATTACK1;
			break;
		}
	case TASK_SPECIAL_ATTACK2:
		{
			m_IdealActivity = ACT_SPECIAL_ATTACK2;
			break;
		}
	case TASK_SET_ACTIVITY:
		{
			m_IdealActivity = (Activity)(int)pTask->flData;
			TaskComplete();
			break;
		}
	case TASK_GET_PATH_TO_ENEMY_LKP:
		{
			if ( BuildRoute ( m_vecEnemyLKP, bits_MF_TO_LOCATION, NULL ) )
			{
				TaskComplete();
			}
			else if (BuildNearestRoute( m_vecEnemyLKP, pev->view_ofs, 0, (m_vecEnemyLKP - pev->origin).Length() ))
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToEnemyLKP failed!!\n" );
				TaskFail();
			}
			break;
		}
	case TASK_GET_PATH_TO_ENEMY:
		{
			CBaseEntity *pEnemy = m_hEnemy;

			if ( pEnemy == NULL )
			{
				TaskFail();
				return;
			}

			if ( BuildRoute ( pEnemy->pev->origin, bits_MF_TO_ENEMY, pEnemy ) )
			{
				TaskComplete();
			}
			else if (BuildNearestRoute( pEnemy->pev->origin, pEnemy->pev->view_ofs, 0, (pEnemy->pev->origin - pev->origin).Length() ))
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToEnemy failed!!\n" );
				TaskFail();
			}
			break;
		}
	case TASK_GET_PATH_TO_ENEMY_CORPSE:
		{
			UTIL_MakeVectors( pev->angles );
			if ( BuildRoute ( m_vecEnemyLKP - gpGlobals->v_forward * 64, bits_MF_TO_LOCATION, NULL ) )
			{
				TaskComplete();
			}
			else
			{
				ALERT ( at_aiconsole, "GetPathToEnemyCorpse failed!!\n" );
				TaskFail();
			}
		}
		break;
	case TASK_GET_PATH_TO_SPOT:
		{
			CBaseEntity *pPlayer = CBaseEntity::Instance( FIND_ENTITY_BY_CLASSNAME( NULL, "player" ) );
			if ( BuildRoute ( m_vecMoveGoal, bits_MF_TO_LOCATION, pPlayer ) )
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" );
				TaskFail();
			}
			break;
		}

	case TASK_GET_PATH_TO_TARGET:
		{
			RouteClear();
			if ( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) )
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToSpot failed!!\n" );
				TaskFail();
			}
			break;
		}
	case TASK_GET_PATH_TO_HINTNODE:// for active idles!
		{
			if ( MoveToLocation( m_movementActivity, 2, WorldGraph.m_pNodes[ m_iHintNode ].m_vecOrigin ) )
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToHintNode failed!!\n" );
				TaskFail();
			}
			break;
		}
	case TASK_GET_PATH_TO_LASTPOSITION:
		{
			m_vecMoveGoal = m_vecLastPosition;

			if ( MoveToLocation( m_movementActivity, 2, m_vecMoveGoal ) )
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToLastPosition failed!!\n" );
				TaskFail();
			}
			break;
		}
	case TASK_GET_PATH_TO_BESTSOUND:
		{
			CSound *pSound;

			pSound = PBestSound();

			if ( pSound && MoveToLocation( m_movementActivity, 2, pSound->m_vecOrigin ) )
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToBestSound failed!!\n" );
				TaskFail();
			}
			break;
		}
case TASK_GET_PATH_TO_BESTSCENT:
		{
			CSound *pScent;

			pScent = PBestScent();

			if ( pScent && MoveToLocation( m_movementActivity, 2, pScent->m_vecOrigin ) )
			{
				TaskComplete();
			}
			else
			{
				// no way to get there =(
				ALERT ( at_aiconsole, "GetPathToBestScent failed!!\n" );
				
				TaskFail();
			}
			break;
		}
	case TASK_RUN_PATH:
		{
			// UNDONE: This is in some default AI and some monsters can't run? -- walk instead?
			if ( LookupActivity( ACT_RUN ) != ACTIVITY_NOT_AVAILABLE )
			{
				m_movementActivity = ACT_RUN;
			}
			else
			{
				m_movementActivity = ACT_WALK;
			}
			TaskComplete();
			break;
		}
	case TASK_WALK_PATH:
		{
			if ( pev->movetype == MOVETYPE_FLY )
			{
				m_movementActivity = ACT_FLY;
			}
			if ( LookupActivity( ACT_WALK ) != ACTIVITY_NOT_AVAILABLE )
			{
				m_movementActivity = ACT_WALK;
			}
			else
			{
				m_movementActivity = ACT_RUN;
			}
			TaskComplete();
			break;
		}
	case TASK_STRAFE_PATH:
		{
			Vector2D	vec2DirToPoint; 
			Vector2D	vec2RightSide;

			// to start strafing, we have to first figure out if the target is on the left side or right side
			UTIL_MakeVectors ( pev->angles );

			vec2DirToPoint = ( m_Route[ 0 ].vecLocation - pev->origin ).Make2D().Normalize();
			vec2RightSide = gpGlobals->v_right.Make2D().Normalize();

			if ( DotProduct ( vec2DirToPoint, vec2RightSide ) > 0 )
			{
				// strafe right
				m_movementActivity = ACT_STRAFE_RIGHT;
			}
			else
			{
				// strafe left
				m_movementActivity = ACT_STRAFE_LEFT;
			}
			TaskComplete();
			break;
		}


	case TASK_WAIT_FOR_MOVEMENT:
		{
			if (FRouteClear())
			{
				TaskComplete();
			}
			break;
		}

	case TASK_EAT:
		{
			Eat( pTask->flData );
			TaskComplete();
			break;
		}
	case TASK_SMALL_FLINCH:
		{
			m_IdealActivity = GetSmallFlinchActivity();
			break;
		}
	case TASK_DIE:
		{
			RouteClear();	
			
			m_IdealActivity = GetDeathActivity();

			pev->deadflag = DEAD_DYING;
			break;
		}
	case TASK_SOUND_WAKE:
		{
			AlertSound();
			TaskComplete();
			break;
		}
	case TASK_SOUND_DIE:
		{
			DeathSound();
			TaskComplete();
			break;
		}
	case TASK_SOUND_IDLE:
		{
			IdleSound();
			TaskComplete();
			break;
		}
	case TASK_SOUND_PAIN:
		{
			PainSound();
			TaskComplete();
			break;
		}
	case TASK_SOUND_DEATH:
		{
			DeathSound();
			TaskComplete();
			break;
		}
	case TASK_SOUND_ANGRY:
		{
			// sounds are complete as soon as we get here, cause we've already played them.
			ALERT ( at_aiconsole, "SOUND\n" );			
			TaskComplete();
			break;
		}
	case TASK_WAIT_FOR_SCRIPT:
		{
			if (m_pCine->m_iszIdle)
			{
				m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszIdle, FALSE );
				if (FStrEq( STRING(m_pCine->m_iszIdle), STRING(m_pCine->m_iszPlay)))
				{
					pev->framerate = 0;
				}
			}
			else
				m_IdealActivity = ACT_IDLE;

			break;
		}
	case TASK_PLAY_SCRIPT:
		{
			pev->movetype = MOVETYPE_FLY;
			ClearBits(pev->flags, FL_ONGROUND);
			m_scriptState = SCRIPT_PLAYING;
			break;
		}
	case TASK_ENABLE_SCRIPT:
		{
			m_pCine->DelayStart( 0 );
			TaskComplete();
			break;
		}
	case TASK_PLANT_ON_SCRIPT:
		{
			if ( m_hTargetEnt != NULL )
			{
				pev->origin = m_hTargetEnt->pev->origin;	// Plant on target
			}

			TaskComplete();
			break;
		}
	case TASK_FACE_SCRIPT:
		{
			if ( m_hTargetEnt != NULL )
			{
				pev->ideal_yaw = UTIL_AngleMod( m_hTargetEnt->pev->angles.y );
			}

			TaskComplete();
			m_IdealActivity = ACT_IDLE;
			RouteClear();
			break;
		}

	case TASK_SUGGEST_STATE:
		{
			m_IdealMonsterState = (MONSTERSTATE)(int)pTask->flData;
			TaskComplete();
			break;
		}

	case TASK_SET_FAIL_SCHEDULE:
		m_failSchedule = (int)pTask->flData;
		TaskComplete();
		break;

	case TASK_CLEAR_FAIL_SCHEDULE:
		m_failSchedule = SCHED_NONE;
		TaskComplete();
		break;

	default:
		{
			ALERT ( at_aiconsole, "No StartTask entry for %d\n", (SHARED_TASKS)pTask->iTask );
			break;
		}
	}
}