MCPcopy Create free account
hub / github.com/JACoders/OpenJK / NPC_ExecuteBState

Function NPC_ExecuteBState

code/game/NPC.cpp:2161–2330  ·  view source on GitHub ↗

=============== NPC_ExecuteBState MCG NPC Behavior state thinking =============== */

Source from the content-addressed store, hash-verified

2159===============
2160*/
2161void NPC_ExecuteBState ( gentity_t *self)//, int msec )
2162{
2163 bState_t bState;
2164
2165 NPC_HandleAIFlags();
2166
2167 //FIXME: these next three bits could be a function call, some sort of setup/cleanup func
2168 //Lookmode must be reset every think cycle
2169 if(NPC->delayScriptTime && NPC->delayScriptTime <= level.time)
2170 {
2171 G_ActivateBehavior( NPC, BSET_DELAYED);
2172 NPC->delayScriptTime = 0;
2173 }
2174
2175 //Clear this and let bState set it itself, so it automatically handles changing bStates... but we need a set bState wrapper func
2176 NPCInfo->combatMove = qfalse;
2177
2178 //Execute our bState
2179 bState = G_CurrentBState( NPCInfo );
2180
2181 //Pick the proper bstate for us and run it
2182 NPC_RunBehavior( self->client->playerTeam, bState );
2183
2184
2185// if(bState != BS_POINT_COMBAT && NPCInfo->combatPoint != -1)
2186// {
2187 //level.combatPoints[NPCInfo->combatPoint].occupied = qfalse;
2188 //NPCInfo->combatPoint = -1;
2189// }
2190
2191 //Here we need to see what the scripted stuff told us to do
2192//Only process snapshot if independant and in combat mode- this would pick enemies and go after needed items
2193// ProcessSnapshot();
2194
2195//Ignore my needs if I'm under script control- this would set needs for items
2196// CheckSelf();
2197
2198 //Back to normal? All decisions made?
2199
2200 //FIXME: don't walk off ledges unless we can get to our goal faster that way, or that's our goal's surface
2201 //NPCPredict();
2202
2203 if ( NPC->enemy )
2204 {
2205 if ( !NPC->enemy->inuse )
2206 {//just in case bState doesn't catch this
2207 G_ClearEnemy( NPC );
2208 }
2209 }
2210
2211 if ( NPC->client->ps.saberLockTime && NPC->client->ps.saberLockEnemy != ENTITYNUM_NONE )
2212 {
2213 NPC_SetLookTarget( NPC, NPC->client->ps.saberLockEnemy, level.time+1000 );
2214 }
2215 else if ( !NPC_CheckLookTarget( NPC ) )
2216 {
2217 if ( NPC->enemy )
2218 {

Callers 1

NPC_ThinkFunction · 0.70

Calls 15

G_CurrentBStateFunction · 0.85
Q_irandFunction · 0.85
NPC_HandleAIFlagsFunction · 0.70
G_ActivateBehaviorFunction · 0.70
NPC_RunBehaviorFunction · 0.70
G_ClearEnemyFunction · 0.70
NPC_SetLookTargetFunction · 0.70
NPC_CheckLookTargetFunction · 0.70
NPC_SetAnimFunction · 0.70
NPC_CheckAttackHoldFunction · 0.70
NPC_ApplyScriptFlagsFunction · 0.70
NPC_AvoidWallsAndCliffsFunction · 0.70

Tested by

no test coverage detected