//========================================================= // Leader boid calls this to form a flock from surrounding boids //========================================================= void CFlockingFlyer :: FormFlock( void ) { if ( !InSquad() ) { // I am my own leader m_pSquadLeader = this; m_pSquadNext = NULL; int squadCount = 1; CBaseEntity *pEntity = NULL; while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, AFLOCK_MAX_RECRUIT_RADIUS )) != NULL) { CBaseMonster *pRecruit = pEntity->MyMonsterPointer( ); if ( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine ) { // Can we recruit this guy? if ( FClassnameIs ( pRecruit->pev, "monster_flyer" ) ) { squadCount++; SquadAdd( (CFlockingFlyer *)pRecruit ); } } } } SetThink( &CFlockingFlyer::IdleThink );// now that flock is formed, go to idle and wait for a player to come along. pev->nextthink = gpGlobals->time; }
void CTalkMonster::AlertFriends( void ) { CBaseEntity *pFriend = NULL; int i; // for each friend in this bsp... for ( i = 0; i < TLK_CFRIENDS; i++ ) { while( ( pFriend = EnumFriends( pFriend, i, true ) ) != nullptr ) { CBaseMonster *pMonster = pFriend->MyMonsterPointer(); if ( pMonster->IsAlive() ) { // don't provoke a friend that's playing a death animation. They're a goner pMonster->m_afMemory |= bits_MEMORY_PROVOKED; } } } }