mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Tank face] Improve angle calculation
This commit is contained in:
@@ -2242,7 +2242,9 @@ float CombatFormationMoveAction::AverageGroupAngle(Unit* from, bool ranged, bool
|
|||||||
{
|
{
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
float average = 0.0f;
|
// float average = 0.0f;
|
||||||
|
float sumX = 0.0f;
|
||||||
|
float sumY = 0.0f;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
|
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
|
||||||
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
|
for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
|
||||||
@@ -2262,11 +2264,17 @@ float CombatFormationMoveAction::AverageGroupAngle(Unit* from, bool ranged, bool
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
cnt++;
|
cnt++;
|
||||||
average += from->GetAngle(member);
|
sumX += member->GetPositionX() - from->GetPositionX();
|
||||||
|
sumY += member->GetPositionY() - from->GetPositionY();
|
||||||
}
|
}
|
||||||
if (cnt)
|
if (cnt == 0)
|
||||||
average /= cnt;
|
return 0.0f;
|
||||||
return average;
|
|
||||||
|
// unnecessary division
|
||||||
|
// sumX /= cnt;
|
||||||
|
// sumY /= cnt;
|
||||||
|
|
||||||
|
return atan2(sumY, sumX);
|
||||||
}
|
}
|
||||||
|
|
||||||
Position CombatFormationMoveAction::GetNearestPosition(const std::vector<Position>& positions)
|
Position CombatFormationMoveAction::GetNearestPosition(const std::vector<Position>& positions)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "IsFacingValue.h"
|
#include "IsFacingValue.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
|
|
||||||
@@ -13,5 +14,5 @@ bool IsFacingValue::Calculate()
|
|||||||
if (!target)
|
if (!target)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return bot->HasInArc(CAST_ANGLE_IN_FRONT, target);
|
return bot->HasInArc(M_PI_2, target);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user