void COsprey::FlyThink( void ) { StudioFrameAdvance( ); pev->nextthink = gpGlobals->time + 0.1; if ( m_pGoalEnt == NULL && !FStringNull(pev->target) )// this monster has a target { m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING( pev->target ) ) ); UpdateGoal( ); } if (gpGlobals->time > m_startTime + m_dTime) { if (m_pGoalEnt->pev->speed == 0) { SetThink( DeployThink ); } do { m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING( m_pGoalEnt->pev->target ) ) ); } while (m_pGoalEnt->pev->speed < 400 && !HasDead()); UpdateGoal( ); } Flight( ); ShowDamage( ); }
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( ); }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CNPC_CombineDropship::Hunt( void ) { // If we have a pickup target, fly to it if ( m_hPickupTarget ) { UpdatePickupNavigation(); } else if ( m_iLandState == LANDING_NO ) { UpdateTrackNavigation(); } // look for enemy GetSenses()->Look( 4092 ); ChooseEnemy(); // don't face player ever, only face nav points Vector desiredDir = GetDesiredPosition() - GetAbsOrigin(); VectorNormalize( desiredDir ); // Face our desired position. m_vecDesiredFaceDir = desiredDir; Flight(); UpdatePlayerDopplerShift( ); }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CBaseHelicopter::Hunt( void ) { UpdateEnemy(); UpdateTrackNavigation( ); UpdateDesiredPosition(); UpdateFacingDirection(); Flight(); UpdatePlayerDopplerShift( ); FireWeapons(); }
void CNihilanth :: HuntThink( void ) { pev->nextthink = gpGlobals->time + 0.1; DispatchAnimEvents( ); StudioFrameAdvance( ); ShootBalls( ); // if dead, force cancelation of current animation if (pev->health <= 0) { SetThink( &CNihilanth::DyingThink ); m_fSequenceFinished = TRUE; return; } // ALERT( at_console, "health %.0f\n", pev->health ); // if damaged, try to abosorb some spheres if (pev->health < gSkillData.nihilanthHealth && AbsorbSphere( )) { pev->health += gSkillData.nihilanthHealth / N_SPHERES; } // get new sequence if (m_fSequenceFinished) { // if (!m_fSequenceLoops) pev->frame = 0; NextActivity( ); ResetSequenceInfo( ); pev->framerate = 2.0 - 1.0 * (pev->health / gSkillData.nihilanthHealth); } // look for current enemy if (m_hEnemy != NULL && m_hRecharger == NULL) { if (FVisible( m_hEnemy )) { if (m_flLastSeen < gpGlobals->time - 5) m_flPrevSeen = gpGlobals->time; m_flLastSeen = gpGlobals->time; m_posTarget = m_hEnemy->pev->origin; m_vecTarget = (m_posTarget - pev->origin).Normalize(); m_vecDesired = m_vecTarget; m_posDesired = Vector( pev->origin.x, pev->origin.y, m_posTarget.z + m_flAdj ); } else { m_flAdj = min( m_flAdj + 10, 1000 ); } } // don't go too high if (m_posDesired.z > m_flMaxZ) m_posDesired.z = m_flMaxZ; // don't go too low if (m_posDesired.z < m_flMinZ) m_posDesired.z = m_flMinZ; Flight( ); }
void CNihilanth :: DyingThink( void ) { pev->nextthink = gpGlobals->time + 0.1; DispatchAnimEvents( ); StudioFrameAdvance( ); if (pev->deadflag == DEAD_NO) { DeathSound( ); pev->deadflag = DEAD_DYING; m_posDesired.z = m_flMaxZ; } if (pev->deadflag == DEAD_DYING) { Flight( ); if (fabs( pev->origin.z - m_flMaxZ ) < 16) { pev->velocity = Vector( 0, 0, 0 ); FireTargets( m_szDeadUse, this, this, USE_ON, 1.0 ); pev->deadflag = DEAD_DEAD; } } if (m_fSequenceFinished) { pev->avelocity.y += RANDOM_FLOAT( -100, 100 ); if (pev->avelocity.y < -100) pev->avelocity.y = -100; if (pev->avelocity.y > 100) pev->avelocity.y = 100; pev->sequence = LookupSequence( "die1" ); } if (m_pBall) { if (m_pBall->pev->renderamt > 0) { m_pBall->pev->renderamt = max( 0, m_pBall->pev->renderamt - 2); } else { UTIL_Remove( m_pBall ); m_pBall = NULL; } } Vector vecDir, vecSrc, vecAngles; UTIL_MakeAimVectors( pev->angles ); int iAttachment = RANDOM_LONG( 1, 4 ); do { vecDir = Vector( RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 ), RANDOM_FLOAT( -1, 1 )); } while (DotProduct( vecDir, vecDir) > 1.0); switch( RANDOM_LONG( 1, 4 )) { case 1: // head vecDir.z = fabs( vecDir.z ) * 0.5; vecDir = vecDir + 2 * gpGlobals->v_up; break; case 2: // eyes if (DotProduct( vecDir, gpGlobals->v_forward ) < 0) vecDir = vecDir * -1; vecDir = vecDir + 2 * gpGlobals->v_forward; break; case 3: // left hand if (DotProduct( vecDir, gpGlobals->v_right ) > 0) vecDir = vecDir * -1; vecDir = vecDir - 2 * gpGlobals->v_right; break; case 4: // right hand if (DotProduct( vecDir, gpGlobals->v_right ) < 0) vecDir = vecDir * -1; vecDir = vecDir + 2 * gpGlobals->v_right; break; } GetAttachment( iAttachment - 1, vecSrc, vecAngles ); TraceResult tr; UTIL_TraceLine( vecSrc, vecSrc + vecDir * 4096, ignore_monsters, ENT(pev), &tr ); MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMENTPOINT ); WRITE_SHORT( entindex() + 0x1000 * iAttachment ); WRITE_COORD( tr.vecEndPos.x); WRITE_COORD( tr.vecEndPos.y); WRITE_COORD( tr.vecEndPos.z); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // frame start WRITE_BYTE( 10 ); // framerate WRITE_BYTE( 5 ); // life WRITE_BYTE( 100 ); // width WRITE_BYTE( 120 ); // noise WRITE_BYTE( 64 ); // r, g, b WRITE_BYTE( 128 ); // r, g, b WRITE_BYTE( 255); // r, g, b WRITE_BYTE( 255 ); // brightness WRITE_BYTE( 10 ); // speed MESSAGE_END(); GetAttachment( 0, vecSrc, vecAngles ); CNihilanthHVR *pEntity = (CNihilanthHVR *)Create( "nihilanth_energy_ball", vecSrc, pev->angles, edict() ); pEntity->pev->velocity = Vector ( RANDOM_FLOAT( -0.7, 0.7 ), RANDOM_FLOAT( -0.7, 0.7 ), 1.0 ) * 600.0; pEntity->GreenBallInit( ); return; }
void CApache :: HuntThink( void ) { StudioFrameAdvance( ); SetNextThink( 0.1 ); ShowDamage( ); if ( m_pGoalEnt == NULL && !FStringNull(pev->target) )// this monster has a target { m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ) ); if (m_pGoalEnt) { m_posDesired = m_pGoalEnt->pev->origin; UTIL_MakeAimVectors( m_pGoalEnt->pev->angles ); m_vecGoal = gpGlobals->v_forward; } } // if (m_hEnemy == NULL) { Look( 4092 ); m_hEnemy = BestVisibleEnemy( ); } // generic speed up if (m_flGoalSpeed < 800) m_flGoalSpeed += 5; if (m_hEnemy != NULL) { // ALERT( at_console, "%s\n", STRING( m_hEnemy->pev->classname ) ); if (FVisible( m_hEnemy )) { if (m_flLastSeen < gpGlobals->time - 5) m_flPrevSeen = gpGlobals->time; m_flLastSeen = gpGlobals->time; m_posTarget = m_hEnemy->Center( ); } else { m_hEnemy = NULL; } } m_vecTarget = (m_posTarget - pev->origin).Normalize(); float flLength = (pev->origin - m_posDesired).Length(); if (m_pGoalEnt) { // ALERT( at_console, "%.0f\n", flLength ); if (flLength < 128) { m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( m_pGoalEnt->pev->target ) ); if (m_pGoalEnt) { m_posDesired = m_pGoalEnt->pev->origin; UTIL_MakeAimVectors( m_pGoalEnt->pev->angles ); m_vecGoal = gpGlobals->v_forward; flLength = (pev->origin - m_posDesired).Length(); } } } else { m_posDesired = pev->origin; } if (flLength > 250) // 500 { // float flLength2 = (m_posTarget - pev->origin).Length() * (1.5 - DotProduct((m_posTarget - pev->origin).Normalize(), pev->velocity.Normalize() )); // if (flLength2 < flLength) if (m_flLastSeen + 90 > gpGlobals->time && DotProduct( (m_posTarget - pev->origin).Normalize(), (m_posDesired - pev->origin).Normalize( )) > 0.25) { m_vecDesired = (m_posTarget - pev->origin).Normalize( ); } else { m_vecDesired = (m_posDesired - pev->origin).Normalize( ); } } else { m_vecDesired = m_vecGoal; } Flight( ); // ALERT( at_console, "%.0f %.0f %.0f\n", gpGlobals->time, m_flLastSeen, m_flPrevSeen ); if ((m_flLastSeen + 1 > gpGlobals->time) && (m_flPrevSeen + 2 < gpGlobals->time)) { if (FireGun( )) { // slow down if we're fireing if (m_flGoalSpeed > 400) m_flGoalSpeed = 400; } // don't fire rockets and gun on easy mode if (g_iSkillLevel == SKILL_EASY) m_flNextRocket = gpGlobals->time + 10.0; } UTIL_MakeAimVectors( pev->angles ); Vector vecEst = (gpGlobals->v_forward * 800 + pev->velocity).Normalize( ); // ALERT( at_console, "%d %d %d %4.2f\n", pev->angles.x < 0, DotProduct( pev->velocity, gpGlobals->v_forward ) > -100, m_flNextRocket < gpGlobals->time, DotProduct( m_vecTarget, vecEst ) ); if ((m_iRockets % 2) == 1) { FireRocket( ); m_flNextRocket = gpGlobals->time + 0.5; if (m_iRockets <= 0) { m_flNextRocket = gpGlobals->time + 10; m_iRockets = 10; } } else if (pev->angles.x < 0 && DotProduct( pev->velocity, gpGlobals->v_forward ) > -100 && m_flNextRocket < gpGlobals->time) { if (m_flLastSeen + 60 > gpGlobals->time) { if (m_hEnemy != NULL) { // make sure it's a good shot if (DotProduct( m_vecTarget, vecEst) > .965) { TraceResult tr; UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096, ignore_monsters, edict(), &tr ); if ((tr.vecEndPos - m_posTarget).Length() < 512) FireRocket( ); } } else { TraceResult tr; UTIL_TraceLine( pev->origin, pev->origin + vecEst * 4096, dont_ignore_monsters, edict(), &tr ); // just fire when close if ((tr.vecEndPos - m_posTarget).Length() < 512) FireRocket( ); } } } }
//------------------------------------------------------------------------------ // Purpose : // Input : // Output : //------------------------------------------------------------------------------ void CBaseHelicopter::Hunt( void ) { UpdateTrackNavigation( ); if( HasCondition( COND_ENEMY_DEAD ) ) { SetEnemy( NULL ); } // Look for my best enemy. If I change enemies, // be sure and change my prevseen/lastseen timers. if( m_lifeState == LIFE_ALIVE ) { GetSenses()->Look( 4092 ); GetEnemies()->RefreshMemories(); ChooseEnemy(); if( HasEnemy() ) { GatherEnemyConditions( GetEnemy() ); if (FVisible( GetEnemy() )) { if (m_flLastSeen < gpGlobals->curtime - 2) { m_flPrevSeen = gpGlobals->curtime; } m_flLastSeen = gpGlobals->curtime; m_vecTargetPosition = GetEnemy()->WorldSpaceCenter(); } } else { // look at where we're going instead m_vecTargetPosition = GetDesiredPosition(); } } else { // If we're dead or dying, forget our enemy and don't look for new ones(sjb) SetEnemy( NULL ); } if ( 1 ) { Vector targetDir = m_vecTargetPosition - GetAbsOrigin(); Vector desiredDir = GetDesiredPosition() - GetAbsOrigin(); VectorNormalize( targetDir ); VectorNormalize( desiredDir ); if ( !IsCrashing() && m_flLastSeen + 5 > gpGlobals->curtime ) //&& DotProduct( targetDir, desiredDir) > 0.25) { // If we've seen the target recently, face the target. //Msg( "Facing Target \n" ); m_vecDesiredFaceDir = targetDir; } else { // Face our desired position. // Msg( "Facing Position\n" ); m_vecDesiredFaceDir = desiredDir; } } else { // Face the way the path corner tells us to. //Msg( "Facing my path corner\n" ); m_vecDesiredFaceDir = GetGoalOrientation(); } Flight(); UpdatePlayerDopplerShift( ); // ALERT( at_console, "%.0f %.0f %.0f\n", gpGlobals->curtime, m_flLastSeen, m_flPrevSeen ); if (m_fHelicopterFlags & BITS_HELICOPTER_GUN_ON) { //if ( (m_flLastSeen + 1 > gpGlobals->curtime) && (m_flPrevSeen + 2 < gpGlobals->curtime) ) { if (FireGun( )) { // slow down if we're firing if (m_flGoalSpeed > m_flMaxSpeedFiring ) { m_flGoalSpeed = m_flMaxSpeedFiring; } } } } if (m_fHelicopterFlags & BITS_HELICOPTER_MISSILE_ON) { AimRocketGun(); } // Finally, forget dead enemies. if( GetEnemy() != NULL && (!GetEnemy()->IsAlive() || GetEnemy()->GetFlags() & FL_NOTARGET) ) { SetEnemy( NULL ); } }