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

Function NPC_MaxDistSquaredForWeapon

codeJK2/game/NPC_combat.cpp:1235–1286  ·  view source on GitHub ↗

FIXME: need a mindist for explosive weapons

Source from the content-addressed store, hash-verified

1233
1234//FIXME: need a mindist for explosive weapons
1235float NPC_MaxDistSquaredForWeapon (void)
1236{
1237 if(NPCInfo->stats.shootDistance > 0)
1238 {//overrides default weapon dist
1239 return NPCInfo->stats.shootDistance * NPCInfo->stats.shootDistance;
1240 }
1241
1242 switch ( NPC->s.weapon )
1243 {
1244 case WP_BLASTER://scav rifle
1245 return 1024 * 1024;//should be shorter?
1246 break;
1247
1248 case WP_BRYAR_PISTOL://prifle
1249 return 1024 * 1024;
1250 break;
1251
1252 case WP_BLASTER_PISTOL://prifle
1253 return 1024 * 1024;
1254 break;
1255
1256 case WP_DISRUPTOR://disruptor
1257 if ( NPCInfo->scriptFlags & SCF_ALT_FIRE )
1258 {
1259 return ( 4096 * 4096 );
1260 }
1261 else
1262 {
1263 return 1024 * 1024;
1264 }
1265 break;
1266/*
1267 case WP_SABER:
1268 return 1024 * 1024;
1269 break;
1270*/
1271 case WP_SABER:
1272 if ( NPC->client && NPC->client->ps.saberLength )
1273 {//FIXME: account for whether enemy and I are heading towards each other!
1274 return (NPC->client->ps.saberLength + NPC->maxs[0]*1.5)*(NPC->client->ps.saberLength + NPC->maxs[0]*1.5);
1275 }
1276 else
1277 {
1278 return 48*48;
1279 }
1280 break;
1281
1282 default:
1283 return 1024 * 1024;//was 0
1284 break;
1285 }
1286}
1287
1288/*
1289-------------------------

Callers 4

NPC_BSSniper_AttackFunction · 0.70
NPC_BSHuntAndKillFunction · 0.70
NPC_EnemyTooFarFunction · 0.70
NPC_CheckAttackHoldFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected