--------------------------------------------- GET UNITS IN WEAPON RANGE ----------------------------------
| 43 | } |
| 44 | //--------------------------------------------- GET UNITS IN WEAPON RANGE ---------------------------------- |
| 45 | Unitset UnitInterface::getUnitsInWeaponRange(WeaponType weapon, const UnitFilter &pred) const |
| 46 | { |
| 47 | // Return if this unit does not exist |
| 48 | if ( !this->exists() ) |
| 49 | return Unitset::none; |
| 50 | |
| 51 | int max = this->getPlayer()->weaponMaxRange(weapon); |
| 52 | |
| 53 | return Broodwar->getUnitsInRectangle(this->getLeft() - max, |
| 54 | this->getTop() - max, |
| 55 | this->getRight() + max, |
| 56 | this->getBottom() + max, |
| 57 | [&](Unit u)->bool |
| 58 | { |
| 59 | // Unit check and unit status |
| 60 | if ( u == this || u->isInvincible() ) |
| 61 | return false; |
| 62 | |
| 63 | // Weapon distance check |
| 64 | int dist = this->getDistance(u); |
| 65 | if ( (weapon.minRange() && dist < weapon.minRange()) || dist > max ) |
| 66 | return false; |
| 67 | |
| 68 | // Weapon behavioural checks |
| 69 | UnitType ut = u->getType(); |
| 70 | if ( (( weapon.targetsOwn() && u->getPlayer() != this->getPlayer() ) || |
| 71 | ( !weapon.targetsAir() && !u->isFlying() ) || |
| 72 | ( !weapon.targetsGround() && u->isFlying() ) || |
| 73 | ( weapon.targetsMechanical() && ut.isMechanical() ) || |
| 74 | ( weapon.targetsOrganic() && ut.isOrganic() ) || |
| 75 | ( weapon.targetsNonBuilding() && !ut.isBuilding() ) || |
| 76 | ( weapon.targetsNonRobotic() && !ut.isRobotic() ) || |
| 77 | ( weapon.targetsOrgOrMech() && (ut.isOrganic() || ut.isMechanical()) )) ) |
| 78 | return false; |
| 79 | |
| 80 | return pred(u); |
| 81 | }); |
| 82 | } |
| 83 | //--------------------------------------------- GET TILE POSITION ------------------------------------------ |
| 84 | TilePosition UnitInterface::getTilePosition() const |
| 85 | { |
nothing calls this directly
no test coverage detected