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

Function NPC_MaxDistSquaredForWeapon

code/game/NPC_combat.cpp:1471–1523  ·  view source on GitHub ↗

FIXME: need a mindist for explosive weapons

Source from the content-addressed store, hash-verified

1469
1470//FIXME: need a mindist for explosive weapons
1471float NPC_MaxDistSquaredForWeapon (void)
1472{
1473 if(NPCInfo->stats.shootDistance > 0)
1474 {//overrides default weapon dist
1475 return NPCInfo->stats.shootDistance * NPCInfo->stats.shootDistance;
1476 }
1477
1478 switch ( NPC->s.weapon )
1479 {
1480 case WP_BLASTER://scav rifle
1481 return 1024 * 1024;//should be shorter?
1482 break;
1483
1484 case WP_BRYAR_PISTOL://prifle
1485 return 1024 * 1024;
1486 break;
1487
1488 case WP_BLASTER_PISTOL://prifle
1489 return 1024 * 1024;
1490 break;
1491
1492 case WP_DISRUPTOR://disruptor
1493 case WP_TUSKEN_RIFLE:
1494 if ( NPCInfo->scriptFlags & SCF_ALT_FIRE )
1495 {
1496 return ( 4096 * 4096 );
1497 }
1498 else
1499 {
1500 return 1024 * 1024;
1501 }
1502 break;
1503/*
1504 case WP_SABER:
1505 return 1024 * 1024;
1506 break;
1507*/
1508 case WP_SABER:
1509 if ( NPC->client && NPC->client->ps.SaberLength() )
1510 {//FIXME: account for whether enemy and I are heading towards each other!
1511 return (NPC->client->ps.SaberLength() + NPC->maxs[0]*1.5)*(NPC->client->ps.SaberLength() + NPC->maxs[0]*1.5);
1512 }
1513 else
1514 {
1515 return 48*48;
1516 }
1517 break;
1518
1519 default:
1520 return 1024 * 1024;//was 0
1521 break;
1522 }
1523}
1524
1525
1526

Callers 4

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

Calls 1

SaberLengthMethod · 0.80

Tested by

no test coverage detected