Permalink
Browse files

qfix #6090

  • Loading branch information...
rt
rt committed Nov 28, 2018
1 parent 176d8f2 commit 0ef398aa1b4c7152723a1024c0c617369b2f101d
Showing with 8 additions and 5 deletions.
  1. +5 −2 rts/Game/GameHelper.cpp
  2. +3 −3 rts/Sim/Weapons/Weapon.cpp
@@ -649,15 +649,18 @@ void CGameHelper::GenerateWeaponTargets(const CWeapon* weapon, const CUnit* avoi
const float3 testPos;
const float aimPosHeight = weapon->aimFromPos.y;
const float minMapHeight = std::max(0.0f, readMap->GetInitMinHeight());
const float minMapHeight = std::max(0.0f, readMap->GetCurrMinHeight());
// how much damage the weapon deals over 1 second
const float secDamage = weaponDmg->GetDefault() * weapon->salvoSize / weapon->reloadTime * GAME_SPEED;
const float heightMod = weaponDef->heightmod;
const float baseRange = weapon->range;
const float rangeBoost = weapon->autoTargetRangeBoost;
const float scanRadius = weapon->GetRange2D(rangeBoost, (aimPosHeight - minMapHeight) * heightMod);
// find theoretical maximum range based on height above lowest point on map
// FIXME: root becomes negative for cannons collapsing range to 0, not legit
// const float scanRadius = weapon->GetRange2D(rangeBoost, (aimPosHeight - minMapHeight) * heightMod);
const float scanRadius = baseRange + rangeBoost + (aimPosHeight - minMapHeight) * heightMod;
// [0] := default, [1,2,3,4,5,6] := target is {avoidee, in bad category, crashing, last attacker, paralyzed, outside unboosted range}
constexpr float tgtPriorityMults[] = {1.0f, 10.0f, 100.0f, 1000.0f, 0.5f, 4.0f, 100000.0f};
@@ -1183,9 +1183,9 @@ float CWeapon::GetStaticRange2D(const CWeapon* w, const WeaponDef* wd, float mod
float CWeapon::GetRange2D(float boost, float ydiff) const
{
const float rangeSq = Square(range + boost);
const float ydiffSq = Square(ydiff);
const float root = rangeSq - ydiffSq;
const float rangeSq = Square(range + boost); // c^2 (hyp)
const float ydiffSq = Square(ydiff); // b^2 (opp)
const float root = rangeSq - ydiffSq; // a^2 (adj)
return (math::sqrt(std::max(root, 0.0f)));
}

0 comments on commit 0ef398a

Please sign in to comment.