Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Cannon respect srcPos on HaveFreeLineOfFire. #1852

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions rts/Sim/Weapons/Cannon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ bool CCannon::HaveFreeLineOfFire(const float3 srcPos, const float3 tgtPos, const
if (projectileSpeed == 0.0f)
return true;

float3 launchDir = CalcWantedDir(tgtPos - weaponMuzzlePos);
float3 targetVec = (tgtPos - weaponMuzzlePos) * XZVector;
float3 launchDir = CalcWantedDir(tgtPos - srcPos);
float3 targetVec = (tgtPos - srcPos) * XZVector;

if (launchDir.SqLength() == 0.0f)
return false;
Expand All @@ -90,15 +90,15 @@ bool CCannon::HaveFreeLineOfFire(const float3 srcPos, const float3 tgtPos, const
// and the prior 10.0f buffer is no longer good enough with the accurate coefficients
// TODO: allow this ignore distance to be set on a per-unit basis
const float groundDist = ((avoidFlags & Collision::NOGROUND) == 0)?
CGround::TrajectoryGroundCol(weaponMuzzlePos, targetVec, groundColCheckDistance, linCoeff, qdrCoeff):
CGround::TrajectoryGroundCol(srcPos, targetVec, groundColCheckDistance, linCoeff, qdrCoeff):
-1.0f;
const float angleSpread = (AccuracyExperience() + SprayAngleExperience()) * 0.6f * 0.9f;

if (groundDist > 0.0f)
return false;

// TODO: add a forcedUserTarget mode (enabled with meta key e.g.) and skip this test accordingly
return (!TraceRay::TestTrajectoryCone(weaponMuzzlePos, targetVec, xzTargetDist, linCoeff, qdrCoeff, angleSpread, owner->allyteam, avoidFlags, owner));
return (!TraceRay::TestTrajectoryCone(srcPos, targetVec, xzTargetDist, linCoeff, qdrCoeff, angleSpread, owner->allyteam, avoidFlags, owner));
}

void CCannon::FireImpl(const bool scriptCall)
Expand Down