AI Perception Behavior Enhancement

From Valve Developer Community
Jump to navigation Jump to search


AI Perception behavior enhancement

In HL2, if a npc heard a sound but don't see the emiter of his one, it will keep staying in place. It will just turn in the direction of the sound for a time before redoing what it did before. With the modification below the NPC will investigate the source of the sound.

Open the ai_basenpc_schedule.cpp file and look for the function SelectAlertSchedule(). Look for the following code:

	if ( HasCondition ( COND_HEAR_DANGER ) ||
			  HasCondition ( COND_HEAR_PLAYER ) ||
			  HasCondition ( COND_HEAR_WORLD  ) ||
			  HasCondition ( COND_HEAR_BULLET_IMPACT ) ||
			  HasCondition ( COND_HEAR_COMBAT ) )
	{
		return SCHED_ALERT_FACE_BESTSOUND;

	}


Replace this code by :


	if ( HasCondition ( COND_HEAR_DANGER ) ||
			  HasCondition ( COND_HEAR_PLAYER ) ||
			  HasCondition ( COND_HEAR_WORLD  ) ||
			  HasCondition ( COND_HEAR_BULLET_IMPACT ) ||
			  HasCondition ( COND_HEAR_COMBAT ) )
	{
		
			  return SCHED_INVESTIGATE_SOUND;//E.Y.E , AI Search for the source of alert  sound
	}

Conclusion

I use this for own project E.Y.E and it runs perfectly.