/* ------------------------- Sentry_Hunt ------------------------- */ void Sentry_Hunt( qboolean visible, qboolean advance ) { float distance, speed; vector3 forward; //If we're not supposed to stand still, pursue the player if ( NPCInfo->standTime < level.time ) { // Only strafe when we can see the player if ( visible ) { Sentry_Strafe(); return; } } //If we don't want to advance, stop here if ( !advance && visible ) return; //Only try and navigate if the player is visible if ( visible == qfalse ) { // Move towards our goal NPCInfo->goalEntity = NPC->enemy; NPCInfo->goalRadius = 12; //Get our direction from the navigator if we can't see our target if ( NPC_GetMoveDirection( &forward, &distance ) == qfalse ) return; } else { VectorSubtract( &NPC->enemy->r.currentOrigin, &NPC->r.currentOrigin, &forward ); VectorNormalize( &forward ); } speed = SENTRY_FORWARD_BASE_SPEED + SENTRY_FORWARD_MULTIPLIER * g_spSkill.integer; VectorMA( &NPC->client->ps.velocity, speed, &forward, &NPC->client->ps.velocity ); }
void Interrogator_Hunt( qboolean visible, qboolean advance ) { float distance, speed; vec3_t forward; Interrogator_PartsMove(); NPC_FaceEnemy(qfalse); //If we're not supposed to stand still, pursue the player if ( NPCInfo->standTime < level.time ) { // Only strafe when we can see the player if ( visible ) { Interrogator_Strafe(); if ( NPCInfo->standTime > level.time ) {//successfully strafed return; } } } //If we don't want to advance, stop here if ( advance == qfalse ) return; //Only try and navigate if the player is visible if ( visible == qfalse ) { // Move towards our goal NPCInfo->goalEntity = NPC->enemy; NPCInfo->goalRadius = 12; //Get our direction from the navigator if we can't see our target if ( NPC_GetMoveDirection( forward, &distance ) == qfalse ) return; } else { VectorSubtract( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin, forward ); distance = VectorNormalize( forward ); } speed = HUNTER_FORWARD_BASE_SPEED + HUNTER_FORWARD_MULTIPLIER * g_spskill.integer; VectorMA( NPC->client->ps.velocity, speed, forward, NPC->client->ps.velocity ); }
/* ------------------------- Remote_Hunt ------------------------- */ void Remote_Hunt( qboolean visible, qboolean advance, qboolean retreat ) { float distance, speed; vec3_t forward; //If we're not supposed to stand still, pursue the player if ( NPCInfo->standTime < level.time ) { // Only strafe when we can see the player if ( visible ) { Remote_Strafe(); return; } } //If we don't want to advance, stop here if ( advance == qfalse && visible == qtrue ) return; //Only try and navigate if the player is visible if ( visible == qfalse ) { // Move towards our goal NPCInfo->goalEntity = NPC->enemy; NPCInfo->goalRadius = 12; //Get our direction from the navigator if we can't see our target if ( NPC_GetMoveDirection( forward, &distance ) == qfalse ) return; } else { VectorSubtract( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin, forward ); distance = VectorNormalize( forward ); } speed = REMOTE_FORWARD_BASE_SPEED + REMOTE_FORWARD_MULTIPLIER * g_npcspskill.integer; if ( retreat == qtrue ) { speed *= -1; } VectorMA( NPC->client->ps.velocity, speed, forward, NPC->client->ps.velocity ); }
void ImperialProbe_Hunt( qboolean visible, qboolean advance ) { float distance, speed; vec3_t forward; NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); //If we're not supposed to stand still, pursue the player if ( NPCInfo->standTime < level.time ) { // Only strafe when we can see the player if ( visible ) { ImperialProbe_Strafe(); return; } } //If we don't want to advance, stop here if ( advance == qfalse ) return; //Only try and navigate if the player is visible if ( visible == qfalse ) { // Move towards our goal NPCInfo->goalEntity = NPC->enemy; NPCInfo->goalRadius = 12; //Get our direction from the navigator if we can't see our target if ( NPC_GetMoveDirection( forward, &distance ) == qfalse ) return; } else { VectorSubtract( NPC->enemy->r.currentOrigin, NPC->r.currentOrigin, forward ); distance = VectorNormalize( forward ); } speed = HUNTER_FORWARD_BASE_SPEED + HUNTER_FORWARD_MULTIPLIER * g_spskill.integer; VectorMA( NPC->client->ps.velocity, speed, forward, NPC->client->ps.velocity ); }
qboolean NPC_MoveToGoal( qboolean tryStraight ) { float distance; vec3_t dir; #if AI_TIMERS int startTime = GetTime(0); #endif// AI_TIMERS //If taking full body pain, don't move if ( PM_InKnockDown( &NPC->client->ps ) || ( ( NPC->s.legsAnim >= BOTH_PAIN1 ) && ( NPC->s.legsAnim <= BOTH_PAIN18 ) ) ) { return qtrue; } /* if( NPC->s.eFlags & EF_LOCKED_TO_WEAPON ) {//If in an emplaced gun, never try to navigate! return qtrue; } */ //rwwFIXMEFIXME: emplaced support //FIXME: if can't get to goal & goal is a target (enemy), try to find a waypoint that has line of sight to target, at least? //Get our movement direction #if 1 if ( NPC_GetMoveDirectionAltRoute( dir, &distance, tryStraight ) == qfalse ) #else if ( NPC_GetMoveDirection( dir, &distance ) == qfalse ) #endif return qfalse; NPCInfo->distToGoal = distance; //Convert the move to angles vectoangles( dir, NPCInfo->lastPathAngles ); if ( (ucmd.buttons&BUTTON_WALKING) ) { NPC->client->ps.speed = NPCInfo->stats.walkSpeed; } else { NPC->client->ps.speed = NPCInfo->stats.runSpeed; } //FIXME: still getting ping-ponging in certain cases... !!! Nav/avoidance error? WTF???!!! //If in combat move, then move directly towards our goal if ( NPC_CheckCombatMove() ) {//keep current facing G_UcmdMoveForDir( NPC, &ucmd, dir ); } else {//face our goal //FIXME: strafe instead of turn if change in dir is small and temporary NPCInfo->desiredPitch = 0.0f; NPCInfo->desiredYaw = AngleNormalize360( NPCInfo->lastPathAngles[YAW] ); //Pitch towards the goal and also update if flying or swimming if ( (NPC->client->ps.eFlags2&EF2_FLYING) )//moveType == MT_FLYSWIM ) { NPCInfo->desiredPitch = AngleNormalize360( NPCInfo->lastPathAngles[PITCH] ); if ( dir[2] ) { float scale = (dir[2] * distance); if ( scale > 64 ) { scale = 64; } else if ( scale < -64 ) { scale = -64; } NPC->client->ps.velocity[2] = scale; //NPC->client->ps.velocity[2] = (dir[2] > 0) ? 64 : -64; } } //Set any final info ucmd.forwardmove = 127; } #if AI_TIMERS navTime += GetTime( startTime ); #endif// AI_TIMERS return qtrue; }
qboolean NPC_MoveToGoal( qboolean tryStraight ) { float distance; vec3_t dir; #if AI_TIMERS int startTime = GetTime(0); #endif// AI_TIMERS //If taking full body pain, don't move if ( PM_InKnockDown( &NPC->client->ps ) || ( ( NPC->s.legsAnim >= BOTH_PAIN1 ) && ( NPC->s.legsAnim <= BOTH_PAIN18 ) ) ) { return qfalse; } #ifdef __DOMINANCE_NPC__ if (NPC->enemy && NPC->s.weapon == WP_SABER && (!NPC_EnemyVisible( NPC, NPC->enemy ) || (Distance(NPC->r.currentOrigin, NPC->enemy->r.currentOrigin) > 96 || NPC->genericValue15 < level.time))) { // Enemy is visible, but out of range for lghtsaber... Move closer... NPC->client->ps.speed = NPCInfo->stats.runSpeed; if (!NPC_FollowRoutes()) { //G_Printf("NPC_FollowRoutes failed!\n"); return qfalse; } return qtrue; } else if (NPC->enemy && NPC_EnemyVisible( NPC, NPC->enemy )) { // Enemy is visible and in range, no need to move at the moment... return qfalse; } else if (NPC->enemy) {// Have an enemy that is not currently visible... if (NPC->s.weapon == WP_SABER && (Distance(NPC->r.currentOrigin, NPC->enemy->r.currentOrigin) > 96 || NPC->genericValue15 < level.time)) { if (NPC->genericValue14 < level.time) { // Give up... NPC->enemy = NULL; NPCInfo->goalEntity = NULL; NPC->longTermGoal = -1; } } else if (NPC->enemy && NPC->genericValue15 < level.time) { if (NPC->genericValue14 < level.time) { // Give up... NPC->enemy = NULL; NPCInfo->goalEntity = NULL; NPC->longTermGoal = -1; } } NPC->client->ps.speed = NPCInfo->stats.runSpeed; if (!NPC_FollowRoutes()) { //G_Printf("NPC_FollowRoutes failed!\n"); return qfalse; } return qtrue; } else {// Dominance: Use bot waypointing AI if it is available! - Unique1 NPC->enemy = NULL; NPCInfo->goalEntity = NULL; NPC->client->ps.speed = NPCInfo->stats.walkSpeed; if (!NPC_FollowRoutes()) { //G_Printf("NPC_FollowRoutes failed!\n"); return qfalse; } return qtrue; } #endif //__DOMINANCE_NPC__ /* if( NPC->s.eFlags & EF_LOCKED_TO_WEAPON ) {//If in an emplaced gun, never try to navigate! return qtrue; } */ //rwwFIXMEFIXME: emplaced support //FIXME: if can't get to goal & goal is a target (enemy), try to find a waypoint that has line of sight to target, at least? //Get our movement direction #if 1 if ( NPC_GetMoveDirectionAltRoute( dir, &distance, tryStraight ) == qfalse ) #else if ( NPC_GetMoveDirection( dir, &distance ) == qfalse ) #endif return qfalse; NPCInfo->distToGoal = distance; //Convert the move to angles vectoangles( dir, NPCInfo->lastPathAngles ); if ( (ucmd.buttons&BUTTON_WALKING) ) { NPC->client->ps.speed = NPCInfo->stats.walkSpeed; } else { NPC->client->ps.speed = NPCInfo->stats.runSpeed; } //FIXME: still getting ping-ponging in certain cases... !!! Nav/avoidance error? WTF???!!! //If in combat move, then move directly towards our goal if ( NPC_CheckCombatMove() ) {//keep current facing G_UcmdMoveForDir( NPC, &ucmd, dir ); } else {//face our goal //FIXME: strafe instead of turn if change in dir is small and temporary NPCInfo->desiredPitch = 0.0f; NPCInfo->desiredYaw = AngleNormalize360( NPCInfo->lastPathAngles[YAW] ); //Pitch towards the goal and also update if flying or swimming if ( (NPC->client->ps.eFlags2&EF2_FLYING) )//moveType == MT_FLYSWIM ) { NPCInfo->desiredPitch = AngleNormalize360( NPCInfo->lastPathAngles[PITCH] ); if ( dir[2] ) { float scale = (dir[2] * distance); if ( scale > 64 ) { scale = 64; } else if ( scale < -64 ) { scale = -64; } NPC->client->ps.velocity[2] = scale; //NPC->client->ps.velocity[2] = (dir[2] > 0) ? 64 : -64; } } //Set any final info ucmd.forwardmove = 127; } #if AI_TIMERS navTime += GetTime( startTime ); #endif// AI_TIMERS return qtrue; }