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

Function ST_Commander

code/game/AI_Stormtrooper.cpp:1853–2193  ·  view source on GitHub ↗

------------------------- ST_Commander Make decisions about who should go where, etc. FIXME: leader (group-decision-making) AI? FIXME: need alternate routes! FIXME: more group voice interaction FIXME: work in pairs? ------------------------- */

Source from the content-addressed store, hash-verified

1851-------------------------
1852*/
1853void ST_Commander( void )
1854{
1855 int i;//, j;
1856 int cp, cpFlags;
1857 AIGroupInfo_t *group = NPCInfo->group;
1858 gentity_t *member;//, *buddy;
1859 qboolean enemyLost = qfalse;
1860 float avoidDist;
1861
1862 group->processed = qtrue;
1863
1864 if ( group->enemy == NULL || group->enemy->client == NULL )
1865 {//hmm, no enemy...?!
1866 return;
1867 }
1868
1869 //FIXME: have this group commander check the enemy group (if any) and see if they have
1870 // superior numbers. If they do, fall back rather than advance. If you have
1871 // superior numbers, advance on them.
1872 //FIXME: find the group commander and have him occasionally give orders when there is speech
1873 //FIXME: start fleeing when only a couple of you vs. a lightsaber, possibly give up if the only one left
1874
1875 SaveNPCGlobals();
1876
1877 if ( group->lastSeenEnemyTime < level.time - 180000 )
1878 {//dissolve the group
1879 ST_Speech( NPC, SPEECH_LOST, 0.0f );
1880 group->enemy->waypoint = NAV::GetNearestNode(group->enemy);
1881 for ( i = 0; i < group->numGroup; i++ )
1882 {
1883 member = &g_entities[group->member[i].number];
1884 SetNPCGlobals( member );
1885 if ( Q3_TaskIDPending( NPC, TID_MOVE_NAV ) )
1886 {//running somewhere that a script requires us to go, don't break from that
1887 continue;
1888 }
1889 if ( !(NPCInfo->scriptFlags&SCF_CHASE_ENEMIES) )
1890 {//not allowed to doMove on my own
1891 continue;
1892 }
1893 //Lost enemy for three minutes? go into search mode?
1894 G_ClearEnemy( NPC );
1895 NPC->waypoint = NAV::GetNearestNode(group->enemy);
1896 if ( NPC->waypoint == WAYPOINT_NONE )
1897 {
1898 NPCInfo->behaviorState = BS_DEFAULT;//BS_PATROL;
1899 }
1900 else if ( group->enemy->waypoint == WAYPOINT_NONE || (NAV::EstimateCostToGoal( NPC->waypoint, group->enemy->waypoint ) >= Q3_INFINITE) )
1901 {
1902 NPC_BSSearchStart( NPC->waypoint, BS_SEARCH );
1903 }
1904 else
1905 {
1906 NPC_BSSearchStart( group->enemy->waypoint, BS_SEARCH );
1907 }
1908 }
1909 group->enemy = NULL;
1910 RestoreNPCGlobals();

Callers 1

NPC_BSST_AttackFunction · 0.70

Calls 15

Q_irandFunction · 0.85
DistanceSquaredFunction · 0.85
NPC_FindCombatPointRetryFunction · 0.85
SaveNPCGlobalsFunction · 0.70
ST_SpeechFunction · 0.70
SetNPCGlobalsFunction · 0.70
Q3_TaskIDPendingFunction · 0.70
G_ClearEnemyFunction · 0.70
NPC_BSSearchStartFunction · 0.70
RestoreNPCGlobalsFunction · 0.70
TIMER_DoneFunction · 0.70
NPC_ClearLOSFunction · 0.70

Tested by

no test coverage detected