/* ------------------------- GM_Move ------------------------- */ static qboolean GM_Move( void ) { NPCInfo->combatMove = qtrue;//always bMove straight toward our goal qboolean moved = NPC_MoveToGoal( qtrue ); navInfo_t info; //Get the bMove info NAV_GetLastMove( info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { GM_HoldPosition(); } } //If our bMove failed, then reset if ( moved == qfalse ) {//FIXME: if we're going to a combat point, need to pick a different one if ( !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) ) {//can't transfer movegoal or stop when a script we're running is waiting to complete GM_HoldPosition(); } } return moved; }
qboolean AI_CheckEnemyCollision( gentity_t *ent, qboolean takeEnemy ) { if ( ent == NULL ) return qfalse; if ( ent->svFlags & SVF_LOCKEDENEMY ) return qfalse; navInfo_t info; NAV_GetLastMove( info ); //See if we've hit something if ( ( info.blocker ) && ( info.blocker != ent->enemy ) ) { if ( ( info.blocker->client ) && ( info.blocker->client->playerTeam == ent->client->enemyTeam ) ) { if ( takeEnemy ) G_SetEnemy( ent, info.blocker ); return qtrue; } } return qfalse; }
static qboolean Sniper_Move( void ) { qboolean moved; navInfo_t info; NPCInfo->combatMove = qtrue;//always move straight toward our goal moved = NPC_MoveToGoal( qtrue ); //Get the move info NAV_GetLastMove( &info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { Sniper_HoldPosition(); } } //If our move failed, then reset if ( moved == qfalse ) {//couldn't get to enemy if ( (NPCInfo->scriptFlags&SCF_CHASE_ENEMIES) && NPCInfo->goalEntity && NPCInfo->goalEntity == NPC->enemy ) {//we were running after enemy //Try to find a combat point that can hit the enemy int cpFlags = (CP_CLEAR|CP_HAS_ROUTE); int cp; if ( NPCInfo->scriptFlags&SCF_USE_CP_NEAREST ) { cpFlags &= ~(CP_FLANK|CP_APPROACH_ENEMY|CP_CLOSEST); cpFlags |= CP_NEAREST; } cp = NPC_FindCombatPoint( NPC->r.currentOrigin, NPC->r.currentOrigin, NPC->r.currentOrigin, cpFlags, 32, -1 ); if ( cp == -1 && !(NPCInfo->scriptFlags&SCF_USE_CP_NEAREST) ) {//okay, try one by the enemy cp = NPC_FindCombatPoint( NPC->r.currentOrigin, NPC->r.currentOrigin, NPC->enemy->r.currentOrigin, CP_CLEAR|CP_HAS_ROUTE|CP_HORZ_DIST_COLL, 32, -1 ); } //NOTE: there may be a perfectly valid one, just not one within CP_COLLECT_RADIUS of either me or him... if ( cp != -1 ) {//found a combat point that has a clear shot to enemy NPC_SetCombatPoint( cp ); NPC_SetMoveGoal( NPC, level.combatPoints[cp].origin, 8, qtrue, cp, NULL ); return moved; } } //just hang here Sniper_HoldPosition(); } return moved; }