AI Programming Overview: Difference between revisions
m (added a stripped down version of RunAI()) |
m (grammar) |
||
Line 1: | Line 1: | ||
[[Category:AI]][[Category:Programming]] | [[Category:AI]][[Category:Programming]] | ||
Each time the NPC thinks with <code>NPCThink()</code> a core method is | Each time the NPC thinks with <code>NPCThink()</code> a core method is executed <code>RunAI()</code>. | ||
<code>RunAI()</code> gathers the NPC's current [[Conditions]] according to its environment and determines the best [[States|State]] it should be in, any kind of logic can influence the NPC's conditions and state including the things it sees or the sounds it hears. | <code>RunAI()</code> gathers the NPC's current [[Conditions]] according to its environment and determines the best [[States|State]] it should be in, any kind of logic can influence the NPC's conditions and state including the things it sees or the sounds it hears. |
Revision as of 06:50, 4 August 2005
Each time the NPC thinks with NPCThink()
a core method is executed RunAI()
.
RunAI()
gathers the NPC's current Conditions according to its environment and determines the best State it should be in, any kind of logic can influence the NPC's conditions and state including the things it sees or the sounds it hears.
The NPC will then determine the best Schedule to run for the given conditions and state, it will maintain any current schedules or interrupt them and run more appropriate schedules to those given conditions and state.
The following links describe states, conditions, schedules and tasks in more detail:
For convenience a stripped down version of the RunAI()
method is shown below in order to give you an idea of how an NPC's core logic works.
void CAI_BaseNPC::RunAI( void ) { g_AIRunTimer.Start(); GatherConditions(); TryRestoreHull(); g_AIPrescheduleThinkTimer.Start(); PrescheduleThink(); g_AIPrescheduleThinkTimer.End(); MaintainSchedule(); PostscheduleThink(); ClearTransientConditions(); g_AIRunTimer.End(); }