/* ------------------------- NPC_BSRemote_Default ------------------------- */ void NPC_BSRemote_Default( void ) { if ( NPCS.NPC->enemy ) Remote_Attack(); else if ( NPCS.NPCInfo->scriptFlags & SCF_LOOK_FOR_ENEMIES ) Remote_Patrol(); else Remote_Idle(); }
/* ------------------------- Remote_Attack ------------------------- */ void Remote_Attack( void ) { float distance; qboolean visible; float idealDist; qboolean advance; qboolean retreat; if ( TIMER_Done(NPC,"spin") ) { TIMER_Set( NPC, "spin", Q_irand( 250, 1500 ) ); NPCInfo->desiredYaw += Q_irand( -200, 200 ); } // Always keep a good height off the ground Remote_MaintainHeight(); // If we don't have an enemy, just idle if ( NPC_CheckEnemyExt(qfalse) == qfalse ) { Remote_Idle(); return; } // Rate our distance to the target, and our visibilty distance = (int) DistanceHorizontalSquared( NPC->r.currentOrigin, NPC->enemy->r.currentOrigin ); visible = NPC_ClearLOS4( NPC->enemy ); //[CoOp] idealDist = MIN_DISTANCE_SQR+(MIN_DISTANCE_SQR*Q_flrand( 0, 1 )); //idealDist = MIN_DISTANCE_SQR+(MIN_DISTANCE_SQR*flrand( 0, 1 )); //[/CoOp] advance = (qboolean)(distance > idealDist*1.25); retreat = (qboolean)(distance < idealDist*0.75); // If we cannot see our target, move to see it if ( visible == qfalse ) { if ( NPCInfo->scriptFlags & SCF_CHASE_ENEMIES ) { Remote_Hunt( visible, advance, retreat ); return; } } Remote_Ranged( visible, advance, retreat ); }