AI Perception Behavior Enhancement: Difference between revisions
Jump to navigation
Jump to search
TomEdwards (talk | contribs) (tweaks) |
mNo edit summary |
||
Line 1: | Line 1: | ||
In HL2, if an idle NPC hears a sound but doesn't see its emitter, it will only turn in the direction of the sound for a | In HL2, if an idle NPC hears a sound but doesn't see its emitter, it will only turn in the direction of the sound for a bit before returning to its previous action. | ||
With the modification below the NPC will | With the modification below the NPC will investigate the source of the sound instead. | ||
Open the <code>ai_basenpc_schedule.cpp</code> file and look for the function <code>SelectAlertSchedule()</code>. Look for the following code: | Open the <code>ai_basenpc_schedule.cpp</code> file and look for the function <code>SelectAlertSchedule()</code>. Look for the following code: | ||
Line 24: | Line 24: | ||
{ | { | ||
return SCHED_INVESTIGATE_SOUND; | |||
} | } | ||
==Conclusion== | ==Conclusion== | ||
With this code,as soon as NPC | With this code, as soon as NPC hears sounds that meet conditions, they will investigate it. | ||
[[Category:Programming]] | [[Category:Programming]] | ||
[[Category:AI Programming]] | [[Category:AI Programming]] |
Revision as of 15:28, 26 December 2006
In HL2, if an idle NPC hears a sound but doesn't see its emitter, it will only turn in the direction of the sound for a bit before returning to its previous action.
With the modification below the NPC will investigate the source of the sound instead.
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 with:
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; }
Conclusion
With this code, as soon as NPC hears sounds that meet conditions, they will investigate it.