//========================================================= // GetSchedule - Decides which type of schedule best suits // the monster's current state and conditions. Then calls // monster's member function to get a pointer to a schedule // of the proper type. //========================================================= int CNPC_AlienGrunt::SelectSchedule( void ) { if ( HasCondition( COND_HEAR_DANGER ) ) { return SCHED_TAKE_COVER_FROM_BEST_SOUND; } switch ( m_NPCState ) { case NPC_STATE_COMBAT: { // dead enemy if ( HasCondition( COND_ENEMY_DEAD ) ) { // call base class, all code to handle dead enemies is centralized there. return BaseClass::SelectSchedule(); } if ( HasCondition( COND_NEW_ENEMY) ) { return SCHED_WAKE_ANGRY; } // zap player! if ( HasCondition ( COND_CAN_MELEE_ATTACK1 ) ) { AttackSound();// this is a total hack. Should be parto f the schedule return SCHED_MELEE_ATTACK1; } if ( HasCondition ( COND_HEAVY_DAMAGE ) ) { return SCHED_SMALL_FLINCH; } // can attack if ( HasCondition ( COND_CAN_RANGE_ATTACK1 ) && OccupyStrategySlotRange( AGRUNT_SQUAD_SLOT_HORNET1, AGRUNT_SQUAD_SLOT_HORNET2 ) ) { return SCHED_RANGE_ATTACK1; } if ( OccupyStrategySlot ( AGRUNT_SQUAD_SLOT_CHASE ) ) { return SCHED_CHASE_ENEMY; } return SCHED_STANDOFF; } } return BaseClass::SelectSchedule(); }
void CNPC_Zombine::Sprint( bool bMadSprint ) { if ( IsSprinting() ) return; OccupyStrategySlotRange( SQUAD_SLOT_ZOMBINE_SPRINT1, SQUAD_SLOT_ZOMBINE_SPRINT2 ); GetNavigator()->SetMovementActivity( ACT_RUN ); float flSprintTime = random->RandomFloat( MIN_SPRINT_TIME, MAX_SPRINT_TIME ); //If holding a grenade then sprint until it blows up. if ( HasGrenade() || bMadSprint == true ) { flSprintTime = 9999; } m_flSprintTime = gpGlobals->curtime + flSprintTime; //Don't sprint for this long after I'm done with this sprint run. m_flSprintRestTime = m_flSprintTime + random->RandomFloat( 2.5f, 5.0f ); EmitSound( "Zombine.Charge" ); }
//----------------------------------------------------------------------------- // Purpose: If requested slot is available return true and take the slot // Otherwise return false // Input : // Output : //----------------------------------------------------------------------------- bool CAI_BaseNPC::OccupyStrategySlot( int squadSlotID ) { return OccupyStrategySlotRange( squadSlotID, squadSlotID ); }
//----------------------------------------------------------------------------- // Purpose: // Input : // Output : //----------------------------------------------------------------------------- int CNPC_Stalker::SelectSchedule( void ) { if ( BehaviorSelectSchedule() ) { return BaseClass::SelectSchedule(); } switch ( m_NPCState ) { case NPC_STATE_IDLE: case NPC_STATE_ALERT: { if( HasCondition(COND_IN_PVS) ) { return SCHED_STALKER_PATROL; } return SCHED_IDLE_STAND; break; } case NPC_STATE_COMBAT: { // ----------- // new enemy // ----------- if( HasCondition( COND_NEW_ENEMY ) ) { if( GetEnemy()->IsPlayer() ) { return SCHED_STALKER_ACQUIRE_PLAYER; } } if( HasCondition( COND_CAN_RANGE_ATTACK1 ) ) { if( OccupyStrategySlotRange(SQUAD_SLOT_ATTACK1, SQUAD_SLOT_ATTACK2) ) { return SCHED_RANGE_ATTACK1; } else { return SCHED_STALKER_PATROL; } } if( !HasCondition(COND_SEE_ENEMY) ) { return SCHED_STALKER_PATROL; } return SCHED_COMBAT_FACE; break; } } // no special cases here, call the base class return BaseClass::SelectSchedule(); }