// 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)); } } }
CBaseMonster *COsprey :: MakeGrunt( Vector vecSrc ) { CBaseEntity *pEntity; CBaseMonster *pGrunt; TraceResult tr; UTIL_TraceLine( vecSrc, vecSrc + Vector( 0, 0, -4096.0), dont_ignore_monsters, ENT(pev), &tr); if ( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP) return NULL; for (int i = 0; i < m_iUnits; i++) { if (m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive()) { if (m_hGrunt[i] != NULL && m_hGrunt[i]->pev->rendermode == kRenderNormal) { m_hGrunt[i]->SUB_StartFadeOut( ); } pEntity = Create( "monster_human_grunt", vecSrc, pev->angles ); pGrunt = pEntity->MyMonsterPointer( ); pGrunt->pev->movetype = MOVETYPE_FLY; pGrunt->pev->velocity = Vector( 0, 0, RANDOM_FLOAT( -196, -128 ) ); pGrunt->SetActivity( ACT_GLIDE ); CBeam *pBeam = CBeam::BeamCreate( "sprites/rope.spr", 10 ); pBeam->PointEntInit( vecSrc + Vector(0,0,112), pGrunt->edict() ); pBeam->SetFlags( FBEAM_SOLID ); pBeam->SetColor( 255, 255, 255 ); pBeam->SetThink(&CBeam:: SUB_Remove ); pBeam->SetNextThink( -4096.0 * tr.flFraction / pGrunt->pev->velocity.z + 0.5 ); // ALERT( at_console, "%d at %.0f %.0f %.0f\n", i, m_vecOrigin[i].x, m_vecOrigin[i].y, m_vecOrigin[i].z ); pGrunt->m_vecLastPosition = m_vecOrigin[i]; m_hGrunt[i] = pGrunt; return pGrunt; } } // ALERT( at_console, "none dead\n"); return NULL; }
// Find an entity that I'm interested in and precache the sounds he'll need in the sequence. void CCineMonster::Activate( void ) { CBaseMonster* pTarget = nullptr; CBaseEntity* pNextTarget = nullptr; // The entity name could be a target name or a classname // Check the targetname while( !pTarget && ( pNextTarget = UTIL_FindEntityByTargetname( pNextTarget, STRING( m_iszEntity ) ) ) != nullptr ) { if( pNextTarget->GetFlags().Any( FL_MONSTER ) ) { pTarget = pNextTarget->MyMonsterPointer(); } } // If no entity with that targetname, check the classname if( !pTarget ) { pNextTarget = nullptr; while( !pTarget && ( pNextTarget = UTIL_FindEntityByClassname( pNextTarget, STRING( m_iszEntity ) ) ) != nullptr ) { pTarget = pNextTarget->MyMonsterPointer(); } } // 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 ) ); } } }