| 1255 | */ |
| 1256 | |
| 1257 | qboolean NPC_FacePosition( vec3_t position, qboolean doPitch ) |
| 1258 | { |
| 1259 | vec3_t muzzle; |
| 1260 | qboolean facing = qtrue; |
| 1261 | |
| 1262 | //Get the positions |
| 1263 | if ( NPC->client && NPC->client->NPC_class == CLASS_GALAKMECH ) |
| 1264 | { |
| 1265 | CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); |
| 1266 | } |
| 1267 | else |
| 1268 | { |
| 1269 | CalcEntitySpot( NPC, SPOT_HEAD_LEAN, muzzle );//SPOT_HEAD |
| 1270 | } |
| 1271 | |
| 1272 | //Find the desired angles |
| 1273 | vec3_t angles; |
| 1274 | |
| 1275 | GetAnglesForDirection( muzzle, position, angles ); |
| 1276 | |
| 1277 | NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); |
| 1278 | NPCInfo->desiredPitch = AngleNormalize360( angles[PITCH] ); |
| 1279 | |
| 1280 | if ( NPC->enemy && NPC->enemy->client && NPC->enemy->client->NPC_class == CLASS_ATST ) |
| 1281 | { |
| 1282 | // FIXME: this is kind of dumb, but it was the easiest way to get it to look sort of ok |
| 1283 | NPCInfo->desiredYaw += Q_flrand( -5, 5 ) + sin( level.time * 0.004f ) * 7; |
| 1284 | NPCInfo->desiredPitch += Q_flrand( -2, 2 ); |
| 1285 | } |
| 1286 | //Face that yaw |
| 1287 | NPC_UpdateAngles( qtrue, qtrue ); |
| 1288 | |
| 1289 | //Find the delta between our goal and our current facing |
| 1290 | float yawDelta = AngleNormalize360( NPCInfo->desiredYaw - ( SHORT2ANGLE( ucmd.angles[YAW] + client->ps.delta_angles[YAW] ) ) ); |
| 1291 | |
| 1292 | //See if we are facing properly |
| 1293 | if ( fabs( yawDelta ) > VALID_ATTACK_CONE ) |
| 1294 | facing = qfalse; |
| 1295 | |
| 1296 | if ( doPitch ) |
| 1297 | { |
| 1298 | //Find the delta between our goal and our current facing |
| 1299 | float currentAngles = ( SHORT2ANGLE( ucmd.angles[PITCH] + client->ps.delta_angles[PITCH] ) ); |
| 1300 | float pitchDelta = NPCInfo->desiredPitch - currentAngles; |
| 1301 | |
| 1302 | //See if we are facing properly |
| 1303 | if ( fabs( pitchDelta ) > VALID_ATTACK_CONE ) |
| 1304 | facing = qfalse; |
| 1305 | } |
| 1306 | |
| 1307 | return facing; |
| 1308 | } |
| 1309 | |
| 1310 | /* |
| 1311 | ------------------------- |
no test coverage detected