//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CAI_OperatorBehavior::GatherConditions( void ) { if( GetGoalEntity() ) { if( GetGoalEntity()->GetState() == OPERATOR_STATE_FINISHED ) { if( IsCurSchedule(SCHED_OPERATOR_OPERATE) ) { // Break us out of the operator schedule if the operation completes. SetCondition(COND_PROVOKED); } m_hGoalEntity.Set(NULL); m_hPositionEnt.Set(NULL); } else { if( CanSeePositionEntity() ) { ClearCondition( COND_OPERATOR_LOST_SIGHT_OF_POSITION ); } else { SetCondition( COND_OPERATOR_LOST_SIGHT_OF_POSITION ); } } } BaseClass::GatherConditions(); // Ignore player pushing. ClearCondition( COND_PLAYER_PUSHING ); }
//----------------------------------------------------------------------------- // Purpose: Move the zombie to the vehicle //----------------------------------------------------------------------------- int CAI_PassengerBehaviorZombie::SelectSchedule( void ) { // See if our enemy got out if ( GetOuter()->GetEnemy() != NULL && EnemyInVehicle() == false ) { if ( GetPassengerState() == PASSENGER_STATE_INSIDE ) { // Exit the vehicle SetCondition( COND_PASSENGER_EXITING ); } else if ( GetPassengerState() == PASSENGER_STATE_OUTSIDE ) { // Our target has left the vehicle and we're outside as well, so give up Disable(); return BaseClass::SelectSchedule(); } } // Entering schedule if ( HasCondition( COND_PASSENGER_ENTERING ) ) { ClearCondition( COND_PASSENGER_ENTERING ); return SCHED_PASSENGER_ZOMBIE_ENTER_VEHICLE; } // Exiting schedule if ( HasCondition( COND_PASSENGER_EXITING ) ) { ClearCondition( COND_PASSENGER_EXITING ); return SCHED_PASSENGER_ZOMBIE_EXIT_VEHICLE; } // Select different schedules based on our state PassengerState_e nState = GetPassengerState(); int nNewSchedule = SCHED_NONE; if ( nState == PASSENGER_STATE_INSIDE ) { nNewSchedule = SelectInsideSchedule(); if ( nNewSchedule != SCHED_NONE ) return nNewSchedule; } else if ( nState == PASSENGER_STATE_OUTSIDE ) { nNewSchedule = SelectOutsideSchedule(); if ( nNewSchedule != SCHED_NONE ) return nNewSchedule; } // Worst case he just stands here Assert(0); return SCHED_IDLE_STAND; }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- void CBaseHelicopter::GatherEnemyConditions( CBaseEntity *pEnemy ) { // ------------------- // If enemy is dead // ------------------- if ( !pEnemy->IsAlive() ) { SetCondition( COND_ENEMY_DEAD ); ClearCondition( COND_SEE_ENEMY ); ClearCondition( COND_ENEMY_OCCLUDED ); return; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAI_PassengerBehaviorZombie::GatherConditions( void ) { BaseClass::GatherConditions(); // Always clear the base conditions ClearCondition( COND_CAN_MELEE_ATTACK1 ); // Behavior when outside the vehicle if ( GetPassengerState() == PASSENGER_STATE_OUTSIDE ) { if ( CanBeOnEnemyVehicle() && CanJumpToAttachToVehicle() ) { SetCondition( COND_CAN_RANGE_ATTACK1 ); } // Determine if we can latch on to the vehicle (out of sight) ClearCondition( COND_PASSENGER_ZOMBIE_CAN_ATTACH_TO_VEHICLE ); CBasePlayer *pPlayer = AI_GetSinglePlayer(); if ( pPlayer != NULL && GetOuter()->GetEnemy() == pPlayer && pPlayer->GetVehicleEntity() == m_hVehicle ) { // Can't be visible to the player and must be close enough bool bNotVisibleToPlayer = ( pPlayer->FInViewCone( GetOuter() ) == false ); float flDistSqr = ( pPlayer->GetAbsOrigin() - GetOuter()->GetAbsOrigin() ).LengthSqr(); bool bInRange = ( flDistSqr < Square(250.0f) ); if ( bNotVisibleToPlayer && bInRange ) { // We can latch on and "enter" the vehicle SetCondition( COND_PASSENGER_ZOMBIE_CAN_ATTACH_TO_VEHICLE ); } else if ( bNotVisibleToPlayer == false && flDistSqr < Square(128.0f) ) { // Otherwise just hit the vehicle in anger SetCondition( COND_CAN_MELEE_ATTACK1 ); } } } // Behavior when on the car if ( GetPassengerState() == PASSENGER_STATE_INSIDE ) { // Check for melee attack if ( GetOuter()->GetNextAttack() < gpGlobals->curtime ) { SetCondition( COND_CAN_MELEE_ATTACK1 ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAI_PolicingBehavior::GatherConditions( void ) { BaseClass::GatherConditions(); // Mapmaker may have removed our goal while we're running our schedule if ( !m_hPoliceGoal ) { Disable(); return; } ClearCondition( COND_POLICE_TARGET_TOO_CLOSE_HARASS ); ClearCondition( COND_POLICE_TARGET_TOO_CLOSE_SUPPRESS ); CBaseEntity *pTarget = m_hPoliceGoal->GetTarget(); if ( pTarget == NULL ) { DevMsg( "ai_goal_police with NULL target entity!\n" ); return; } // See if we need to knock out our target immediately if ( ShouldKnockOutTarget( pTarget ) ) { SetCondition( COND_POLICE_TARGET_TOO_CLOSE_SUPPRESS ); } float flDistSqr = ( m_hPoliceGoal->WorldSpaceCenter() - pTarget->WorldSpaceCenter() ).Length2DSqr(); float radius = ( m_hPoliceGoal->GetRadius() * PATROL_RADIUS_RATIO ); float zDiff = fabs( m_hPoliceGoal->WorldSpaceCenter().z - pTarget->WorldSpaceCenter().z ); // If we're too far away, don't bother if ( flDistSqr < (radius*radius) && zDiff < 32.0f ) { SetCondition( COND_POLICE_TARGET_TOO_CLOSE_HARASS ); if ( flDistSqr < (m_hPoliceGoal->GetRadius()*m_hPoliceGoal->GetRadius()) ) { SetCondition( COND_POLICE_TARGET_TOO_CLOSE_SUPPRESS ); } } // If we're supposed to stop chasing (aggression over), return if ( m_bTargetIsHostile && m_flAggressiveTime < gpGlobals->curtime && IsCurSchedule(SCHED_CHASE_ENEMY) ) { // Force me to re-evaluate my schedule GetOuter()->ClearSchedule( "Stopped chasing, aggression over" ); } }
int CRebelZombie::SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode ) { if ( HasCondition( COND_BLOCKED_BY_DOOR ) && m_hBlockingDoor != NULL ) { ClearCondition( COND_BLOCKED_BY_DOOR ); if ( m_NextTimeToStartDoorBash.Expired() && failedSchedule != SCHED_ZOMBIE_BASH_DOOR ) return SCHED_ZOMBIE_BASH_DOOR; m_hBlockingDoor = NULL; } if ( failedSchedule != SCHED_ZOMBIE_CHARGE_ENEMY && IsPathTaskFailure( taskFailCode ) && random->RandomInt( 1, 100 ) < 50 ) { return SCHED_ZOMBIE_CHARGE_ENEMY; } if ( failedSchedule != SCHED_ZOMBIE_WANDER_ANGRILY && ( failedSchedule == SCHED_TAKE_COVER_FROM_ENEMY || failedSchedule == SCHED_CHASE_ENEMY_FAILED ) ) { return SCHED_ZOMBIE_WANDER_ANGRILY; } return BaseClass::SelectFailSchedule( failedSchedule, failedTask, taskFailCode ); }
//------------------------------------------------------------------------------ // Purpose : The main think function for the helicopters // Input : // Output : //------------------------------------------------------------------------------ void CBaseHelicopter::HelicopterThink( void ) { SetNextThink( gpGlobals->curtime + HELICOPTER_THINK_INTERVAL ); // Don't keep this around for more than one frame. ClearCondition( COND_ENEMY_DEAD ); // Animate and dispatch animation events. StudioFrameAdvance( ); DispatchAnimEvents( this ); PrescheduleThink(); ShowDamage( ); // ----------------------------------------------- // If AI is disabled, kill any motion and return // ----------------------------------------------- if (CAI_BaseNPC::m_nDebugBits & bits_debugDisableAI) { SetAbsVelocity( vec3_origin ); SetLocalAngularVelocity( vec3_angle ); SetNextThink( gpGlobals->curtime + HELICOPTER_THINK_INTERVAL ); return; } Hunt(); HelicopterPostThink(); }
//------------------------------------------------------------------------------ // Purpose : Draw attack beam and do damage / decals // Input : // Output : //------------------------------------------------------------------------------ void CNPC_Stalker::KillAttackBeam(void) { if ( !m_pBeam ) return; // Kill sound StopSound(m_pBeam->entindex(), "NPC_Stalker.BurnWall" ); StopSound(m_pBeam->entindex(), "NPC_Stalker.BurnFlesh" ); UTIL_Remove( m_pLightGlow ); UTIL_Remove( m_pBeam); m_pBeam = NULL; m_bPlayingHitWall = false; m_bPlayingHitFlesh = false; SetThink(&CNPC_Stalker::CallNPCThink); if ( m_flNextNPCThink > gpGlobals->curtime ) { SetNextThink( m_flNextNPCThink ); } // Beam has to recharge m_fBeamRechargeTime = gpGlobals->curtime + STALKER_LASER_RECHARGE; ClearCondition( COND_CAN_RANGE_ATTACK1 ); RelaxAim(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNPC_Assassin::GatherEnemyConditions( CBaseEntity *pEnemy ) { ClearCondition( COND_ASSASSIN_ENEMY_TARGETTING_ME ); BaseClass::GatherEnemyConditions( pEnemy ); // See if we're being targetted specifically if ( HasCondition( COND_ENEMY_FACING_ME ) ) { Vector enemyDir = GetAbsOrigin() - pEnemy->GetAbsOrigin(); VectorNormalize( enemyDir ); Vector enemyBodyDir; CBasePlayer *pPlayer = ToBasePlayer( pEnemy ); if ( pPlayer != NULL ) { enemyBodyDir = pPlayer->BodyDirection3D(); } else { AngleVectors( pEnemy->GetAbsAngles(), &enemyBodyDir ); } float enemyDot = DotProduct( enemyBodyDir, enemyDir ); //FIXME: Need to refine this a bit if ( enemyDot > 0.97f ) { SetCondition( COND_ASSASSIN_ENEMY_TARGETTING_ME ); } } }
void CAI_PlayerAlly::OnChangeRunningBehavior( CAI_BehaviorBase *pOldBehavior, CAI_BehaviorBase *pNewBehavior ) { BaseClass::OnChangeRunningBehavior( pOldBehavior, pNewBehavior ); CAI_FollowBehavior *pFollowBehavior; if ( dynamic_cast<CAI_FollowBehavior *>(pNewBehavior) != NULL ) { GetExpresser()->SetSpokeConcept( TLK_HELLO, NULL ); // Don't say hi after you've started following if ( IsOkToCombatSpeak() ) Speak( TLK_USE ); SetSpeechTarget( GetTarget() ); ClearCondition( COND_PLAYER_PUSHING ); } else if ( ( pFollowBehavior = dynamic_cast<CAI_FollowBehavior *>(pOldBehavior) ) != NULL ) { if ( !(m_afMemory & bits_MEMORY_PROVOKED) ) { if ( IsOkToCombatSpeak() ) { if ( pFollowBehavior->GetFollowTarget() == NULL ) Speak( TLK_UNUSE ); else Speak( TLK_STOP ); } SetSpeechTarget( FindNearestFriend(true) ); } } }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- bool CBaseHelicopter::ChooseEnemy( void ) { // See if there's a new enemy. CBaseEntity *pNewEnemy; pNewEnemy = BestEnemy(); if ( pNewEnemy != GetEnemy() ) { if ( pNewEnemy != NULL ) { // New enemy! Clear the timers and set conditions. SetEnemy( pNewEnemy ); m_flLastSeen = m_flPrevSeen = gpGlobals->curtime; } else { SetEnemy( NULL ); SetState( NPC_STATE_ALERT ); } return true; } else { ClearCondition( COND_NEW_ENEMY ); return false; } }
//--------------------------------------------------------- //--------------------------------------------------------- void CNPC_Combine_Cannon::InputDisableSniper( inputdata_t &inputdata ) { ClearCondition( COND_CANNON_ENABLED ); SetCondition( COND_CANNON_DISABLED ); m_fEnabled = false; }
void CNPC_Hydra::CheckLength( ) { int i; ClearCondition( COND_HYDRA_SNAGGED ); ClearCondition( COND_HYDRA_NOSTUCK ); ClearCondition( COND_HYDRA_OVERSTRETCH ); m_bHasStuckSegments = m_body[m_body.Count() - 1].bStuck; m_flCurrentLength = 0; for (i = 1; i < m_body.Count() - 1; i++) { float length = (m_body[i+1].vecPos - m_body[i].vecPos).Length(); Assert( m_body[i+1].vecPos.IsValid( ) ); Assert( m_body[i].vecPos.IsValid( ) ); Assert( IsFinite( length ) ); m_body[i].flActualLength = length; m_flCurrentLength += length; // check for over streatched segements if (length > m_idealSegmentLength * 3.0 && (m_body[i].bStuck || m_body[i+1].bStuck)) { //NDebugOverlay::Line( m_body[i].vecPos, m_body[i+1].vecPos, 255, 0, 0, true, 1.0); SetCondition( COND_HYDRA_SNAGGED ); } if (m_body[i].bStuck) { m_bHasStuckSegments = true; } } if (m_flCurrentLength > HYDRA_MAX_LENGTH) // FIXME { SetCondition( COND_HYDRA_OVERSTRETCH ); } if (!m_bHasStuckSegments) { SetCondition( COND_HYDRA_NOSTUCK ); } }
void CNPCSimpleTalker::OnStartingFollow( CBaseEntity *pTarget ) { GetExpresser()->SetSpokeConcept( TLK_HELLO, NULL ); // Don't say hi after you've started following if ( IsOkToSpeak() ) // don't speak if idle talk is blocked. player commanded/use follow will always speak Speak( TLK_STARTFOLLOW ); SetSpeechTarget( GetTarget() ); ClearCondition( COND_PLAYER_PUSHING ); }
void CNPC_Bullsquid::RemoveIgnoredConditions( void ) { if ( m_flHungryTime > gpGlobals->curtime ) ClearCondition( COND_SQUID_SMELL_FOOD ); if ( gpGlobals->curtime - m_flLastHurtTime <= 20 ) { // haven't been hurt in 20 seconds, so let the squid care about stink. ClearCondition( COND_SMELL ); } if ( GetEnemy() != NULL ) { // ( Unless after a tasty headcrab, yumm ^_^ ) if ( FClassnameIs( GetEnemy(), "monster_headcrab" ) ) ClearCondition( COND_SMELL ); } }
//--------------------------------------------------------- //--------------------------------------------------------- int CFastZombie::SelectSchedule ( void ) { if ( HasCondition( COND_ZOMBIE_RELEASECRAB ) ) { // Death waits for no man. Or zombie. Or something. return SCHED_ZOMBIE_RELEASECRAB; } if ( HasCondition( COND_FASTZOMBIE_CLIMB_TOUCH ) ) { return SCHED_FASTZOMBIE_UNSTICK_JUMP; } switch ( m_NPCState ) { case NPC_STATE_COMBAT: if ( HasCondition( COND_LOST_ENEMY ) || ( HasCondition( COND_ENEMY_UNREACHABLE ) && MustCloseToAttack() ) ) { // Set state to alert and recurse! SetState( NPC_STATE_ALERT ); return SelectSchedule(); } break; case NPC_STATE_ALERT: if ( HasCondition( COND_LOST_ENEMY ) || ( HasCondition( COND_ENEMY_UNREACHABLE ) && MustCloseToAttack() ) ) { ClearCondition( COND_LOST_ENEMY ); ClearCondition( COND_ENEMY_UNREACHABLE ); SetEnemy( NULL ); #ifdef DEBUG_ZOMBIES DevMsg("Wandering\n"); #endif // Just lost track of our enemy. // Wander around a bit so we don't look like a dingus. return SCHED_ZOMBIE_WANDER_MEDIUM; } break; } return BaseClass::SelectSchedule(); }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void CAI_AssaultBehavior::GatherConditions( void ) { BaseClass::GatherConditions(); // If this NPC is moving towards an assault point which // a) Has a Next Assault Point, and // b) Is flagged to Clear On Arrival, // then hit and clear the assault point (fire all entity I/O) and move on to the next one without // interrupting the NPC's schedule. This provides a more fluid movement from point to point. if( IsCurSchedule( SCHED_MOVE_TO_ASSAULT_POINT ) && hl2_episodic.GetBool() ) { if( m_hAssaultPoint && m_hAssaultPoint->HasSpawnFlags(SF_ASSAULTPOINT_CLEARONARRIVAL) && m_hAssaultPoint->m_NextAssaultPointName != NULL_STRING ) { float flDist = GetAbsOrigin().DistTo( m_hAssaultPoint->GetAbsOrigin() ); if( flDist <= GetOuter()->GetMotor()->MinStoppingDist() ) { OnHitAssaultPoint(); ClearAssaultPoint(); AI_NavGoal_t goal( m_hAssaultPoint->GetAbsOrigin() ); goal.pTarget = m_hAssaultPoint; if ( GetNavigator()->SetGoal( goal ) == false ) { TaskFail( "Can't refresh assault path" ); } } } if( OnStrictAssault() ) { // Don't get distracted. Die trying if you have to. ClearCondition( COND_HEAR_DANGER ); } } if ( IsForcingCrouch() && GetOuter()->IsCrouching() ) { ClearCondition( COND_HEAR_BULLET_IMPACT ); } }
int CAI_PlayerAlly::PlayScriptedSentence( const char *pszSentence, float delay, float volume, soundlevel_t soundlevel, bool bConcurrent, CBaseEntity *pListener ) { if ( !bConcurrent ) ShutUpFriends(); ClearCondition( COND_PLAYER_PUSHING ); // Forget about moving! I've got something to say! int sentenceIndex = BaseClass::PlayScriptedSentence( pszSentence, delay, volume, soundlevel, bConcurrent, pListener ); SetSpeechTarget( pListener ); return sentenceIndex; }
//----------------------------------------------------------------------------- // Purpose: // Input : *pOther - //----------------------------------------------------------------------------- void CNPC_AntlionGrub::EndTouch( CBaseEntity *pOther ) { ClearCondition( COND_ANTLIONGRUB_BEING_SQUASHED ); m_bSquashValid = false; /* CSoundEnvelopeController::GetController().SoundChangePitch( m_pVoiceSound, 100, 0.5f ); CSoundEnvelopeController::GetController().SoundChangeVolume( m_pVoiceSound, 0.0f, 1.0f ); */ m_flPlaybackRate = 1.0f; }
//------------------------------------------------------------------------------ // Purpose: sets / clears conditions for when the behavior is active. this is // generally a larger set of conditions to interrupt any tasks. //------------------------------------------------------------------------------ void CAI_ASW_HealOtherBehavior::GatherConditions( ) { BaseClass::GatherConditions(); ClearCondition( COND_HEAL_OTHER_HAS_FULL_HEALTH ); // needed? if ( GetTarget() != NULL ) { if ( GetTarget()->m_iHealth == GetTarget()->m_iMaxHealth ) { SetCondition( COND_HEAL_OTHER_HAS_FULL_HEALTH ); } } }
int CNPC_Zombine::SelectSchedule( void ) { if ( GetHealth() <= 0 ) return BaseClass::SelectSchedule(); if ( HasCondition( COND_ZOMBINE_GRENADE ) ) { ClearCondition( COND_ZOMBINE_GRENADE ); return SCHED_ZOMBINE_PULL_GRENADE; } return BaseClass::SelectSchedule(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CNPC_VehicleDriver::SelectSchedule( void ) { // Vehicle driver hangs in the air inside the vehicle, so we never need to fall to ground ClearCondition( COND_FLOATING_OFF_GROUND ); if ( HasSpawnFlags(SF_VEHICLEDRIVER_INACTIVE) ) { SetState( NPC_STATE_IDLE ); return SCHED_VEHICLEDRIVER_INACTIVE; } if ( GetGoalEnt() ) return SCHED_VEHICLEDRIVER_DRIVE_PATH; switch ( m_NPCState ) { case NPC_STATE_IDLE: break; case NPC_STATE_ALERT: break; case NPC_STATE_COMBAT: { if ( HasCondition(COND_NEW_ENEMY) || HasCondition( COND_ENEMY_DEAD ) ) return BaseClass::SelectSchedule(); if ( HasCondition(COND_SEE_ENEMY) ) { // we can see the enemy if ( HasCondition(COND_CAN_RANGE_ATTACK2) ) return SCHED_RANGE_ATTACK2; if ( HasCondition(COND_CAN_RANGE_ATTACK1) ) return SCHED_RANGE_ATTACK1; // What to do here? Not necessarily easy to face enemy. //if ( HasCondition(COND_NOT_FACING_ATTACK) ) //return SCHED_COMBAT_FACE; } // We can see him, but can't shoot him. Just wait and hope he comes closer. return SCHED_VEHICLEDRIVER_COMBAT_WAIT; } break; } return BaseClass::SelectSchedule(); }
//----------------------------------------------------------------------------- // Purpose: // // // Output : //----------------------------------------------------------------------------- void CNPC_RollerDozer::GatherConditions( void ) { BaseClass::GatherConditions(); if( gpGlobals->curtime > m_flTimeDebrisSearch && m_hDebris == NULL ) { m_flTimeDebrisSearch = gpGlobals->curtime + ROLLERDOZER_DEBRIS_FREQUENCY; m_hDebris = FindDebris(); if( m_hDebris == NULL) { ClearCondition( COND_ROLLERDOZER_FOUND_DEBRIS ); } else { SetCondition( COND_ROLLERDOZER_FOUND_DEBRIS ); } } }
int CNPC_Zombine::SelectSchedule( void ) { if ( GetHealth() <= 0 ) return BaseClass::SelectSchedule(); if ( HasCondition( COND_ZOMBINE_GRENADE ) ) { ClearCondition( COND_ZOMBINE_GRENADE ); return SCHED_ZOMBINE_PULL_GRENADE; } if (m_NPCState == NPC_STATE_IDLE || m_NPCState == NPC_STATE_ALERT) { return SCHED_PATROL_WALK_LOOP; } return BaseClass::SelectSchedule(); }
void CASW_Alien_Jumper::PrescheduleThink( void ) { //New Enemy? Try to jump at him. if ( HasCondition( COND_NEW_ENEMY ) ) { m_flJumpTime = 0.0f; } if ( ShouldJump() ) { SetCondition( COND_ASW_ALIEN_CAN_JUMP ); } else { ClearCondition( COND_ASW_ALIEN_CAN_JUMP ); } BaseClass::PrescheduleThink(); }
void CZombie::GatherConditions( void ) { BaseClass::GatherConditions(); static int conditionsToClear[] = { COND_BLOCKED_BY_DOOR, COND_DOOR_OPENED, COND_ZOMBIE_CHARGE_TARGET_MOVED, }; ClearConditions( conditionsToClear, ARRAYSIZE( conditionsToClear ) ); if ( m_hBlockingDoor == NULL || ( m_hBlockingDoor->m_toggle_state == TS_AT_TOP || m_hBlockingDoor->m_toggle_state == TS_GOING_UP ) ) { ClearCondition( COND_BLOCKED_BY_DOOR ); if ( m_hBlockingDoor != NULL ) { SetCondition( COND_DOOR_OPENED ); m_hBlockingDoor = NULL; } } else SetCondition( COND_BLOCKED_BY_DOOR ); if ( ConditionInterruptsCurSchedule( COND_ZOMBIE_CHARGE_TARGET_MOVED ) ) { if ( GetNavigator()->IsGoalActive() ) { const float CHARGE_RESET_TOLERANCE = 60.0; if ( !GetEnemy() || ( m_vPositionCharged - GetEnemyLKP() ).Length() > CHARGE_RESET_TOLERANCE ) { SetCondition( COND_ZOMBIE_CHARGE_TARGET_MOVED ); } } } }
void CNPC_CombineShot::OnListened() { BaseClass::OnListened(); if ( HasCondition( COND_HEAR_DANGER ) && HasCondition( COND_HEAR_PHYSICS_DANGER ) ) { if ( HasInterruptCondition( COND_HEAR_DANGER ) ) { ClearCondition( COND_HEAR_PHYSICS_DANGER ); } } // debugging to find missed schedules #if 0 if ( HasCondition( COND_HEAR_DANGER ) && !HasInterruptCondition( COND_HEAR_DANGER ) ) { DevMsg("Ignore danger in %s\n", GetCurSchedule()->GetName() ); } #endif }
//------------------------------------------------------------------------------ // Purpose: routine called to start when a task initially starts // Input : pTask - the task structure //------------------------------------------------------------------------------ void CAI_ASW_FlickBehavior::StartTask( const Task_t *pTask ) { switch( pTask->iTask ) { case TASK_SHIELD_FLICK: { ClearCondition( COND_SHIELD_CAN_FLICK ); m_pPickedFlick = GetFlickActivity(); if ( m_pPickedFlick != NULL ) { GetOuter()->RestartGesture( m_pPickedFlick->m_Activity ); } } break; default: BaseClass::StartTask( pTask ); break; } }
//------------------------------------------------------------------------------ // Purpose : The main think function for the helicopters // Input : // Output : //------------------------------------------------------------------------------ void CBaseHelicopter::HelicopterThink( void ) { CheckPVSCondition(); SetNextThink( gpGlobals->curtime + HELICOPTER_THINK_INTERVAL ); // Don't keep this around for more than one frame. ClearCondition( COND_ENEMY_DEAD ); // Animate and dispatch animation events. StudioFrameAdvance( ); DispatchAnimEvents( this ); PrescheduleThink(); if ( IsMarkedForDeletion() ) return; ShowDamage( ); // ----------------------------------------------- // If AI is disabled, kill any motion and return // ----------------------------------------------- if (CAI_BaseNPC::m_nDebugBits & bits_debugDisableAI) { SetAbsVelocity( vec3_origin ); SetLocalAngularVelocity( vec3_angle ); SetNextThink( gpGlobals->curtime + HELICOPTER_THINK_INTERVAL ); return; } Hunt(); // Finally, forget dead enemies, or ones we've been told to ignore. if( GetEnemy() != NULL && (!GetEnemy()->IsAlive() || GetEnemy()->GetFlags() & FL_NOTARGET || IRelationType( GetEnemy() ) == D_NU ) ) { SetEnemy( NULL ); } HelicopterPostThink(); }
int CNPC_Dog::SelectSchedule ( void ) { ClearCondition( COND_DOG_LOST_PHYSICS_ENTITY ); if ( GetState() == NPC_STATE_SCRIPT || IsInAScript() ) return BaseClass::SelectSchedule(); if ( BehaviorSelectSchedule() ) return BaseClass::SelectSchedule(); if ( m_bDoWaitforObjectBehavior == true ) { if ( m_hPhysicsEnt ) return SCHED_DOG_CATCH_OBJECT; } if ( m_bDoCatchThrowBehavior == true ) { if ( m_flTimeToCatch < 0.1 && m_flNextSwat <= gpGlobals->curtime ) { return SCHED_DOG_FIND_OBJECT; } if ( m_flTimeToCatch > gpGlobals->curtime && m_hPhysicsEnt ) return SCHED_DOG_CATCH_OBJECT; } else { if ( m_hPhysicsEnt ) { if ( m_bHasObject == true ) { return SCHED_DOG_WAIT_THROW_OBJECT; } } } return BaseClass::SelectSchedule(); }