MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ShotIsClear

Function ShotIsClear

scripts/AIGame3.cpp:546–571  ·  view source on GitHub ↗

Analyzes data to determine if shot is clear

Source from the content-addressed store, hash-verified

544
545// Analyzes data to determine if shot is clear
546int ShotIsClear(float risk_factor) {
547 int j;
548
549 if (num_shot_path_positions == 0)
550 return CS_NO_PATH;
551
552 // If final shot path position contains shooter, don't shoot!
553 if (ShotPathPositions[num_shot_path_positions - 1].contains_shooter)
554 return CS_SHOOTER_IN_WAY;
555
556 for (j = 0; j < num_shot_path_positions; j++) {
557 // Check and see if shooter is in the way (ok if it's the first position)
558 if (ShotPathPositions[j].contains_shooter && j != 0)
559 return CS_SHOOTER_IN_WAY;
560
561 // Check if there are any friendlies or neutrals in the way
562 if ((ShotPathPositions[j].num_friends + ShotPathPositions[j].num_neutrals) > 0)
563 return CS_FRIEND_IN_WAY;
564
565 // Check if any enemies are in the way
566 if (ShotPathPositions[j].num_enemies > 0 && !ShotPathPositions[j].contains_shooter)
567 return CS_ALL_CLEAR;
568 }
569
570 return CS_NO_ENEMY;
571}
572
573// Checks to see if object has a clear shot
574int HasClearShot(tShotData *shot_data) {

Callers 1

HasClearShotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected