diff options
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index a601a51d4fb..3b39fdefaf5 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3448,6 +3448,15 @@ bool Unit::isInBack(Unit const* target, float distance, float arc) const return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); } +bool Unit::isInLine(Unit const* target, float distance) const +{ + if(!HasInArc(M_PI, target) || !IsWithinDistInMap(target, distance)) return false; + float width = (GetObjectSize() / 2 + target->GetObjectSize()) / 2; + float angle = GetAngle(target); + angle -= GetOrientation(); + return abs(sin(angle)) * distance < width; +} + bool Unit::isInAccessablePlaceFor(Creature const* c) const { if(IsInWater()) |