mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 17:09:08 +00:00
smarter dps target and tank target
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include "AttackersValue.h"
|
||||
#include "PlayerbotAIConfig.h"
|
||||
#include "TankTargetValue.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
@@ -41,8 +42,53 @@ class FindTargetForTankStrategy : public FindNonCcTargetStrategy
|
||||
float minThreat;
|
||||
};
|
||||
|
||||
class FindTankTargetSmartStrategy : public FindTargetStrategy
|
||||
{
|
||||
public:
|
||||
FindTankTargetSmartStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI) { }
|
||||
|
||||
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
|
||||
{
|
||||
if (Group* group = botAI->GetBot()->GetGroup())
|
||||
{
|
||||
ObjectGuid guid = group->GetTargetIcon(4);
|
||||
if (guid && attacker->GetGUID() == guid)
|
||||
return;
|
||||
}
|
||||
if (!attacker->IsAlive()) {
|
||||
return;
|
||||
}
|
||||
if (!result || IsBetter(attacker, result)) {
|
||||
result = attacker;
|
||||
}
|
||||
}
|
||||
bool IsBetter(Unit* new_unit, Unit* old_unit) {
|
||||
Player* bot = botAI->GetBot();
|
||||
float new_threat = new_unit->GetThreatMgr().GetThreat(bot);
|
||||
float old_threat = old_unit->GetThreatMgr().GetThreat(bot);
|
||||
float new_dis = bot->GetDistance(new_unit);
|
||||
float old_dis = bot->GetDistance(old_unit);
|
||||
// hasAggro? -> withinMelee? -> threat
|
||||
if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) {
|
||||
return true;
|
||||
}
|
||||
int32_t interval = GetIntervalLevel(new_unit);
|
||||
if (interval == 1) {
|
||||
return new_dis < old_dis;
|
||||
}
|
||||
return new_threat < old_threat;
|
||||
}
|
||||
int32_t GetIntervalLevel(Unit* unit) {
|
||||
if (!botAI->HasAggro(unit)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
Unit* TankTargetValue::Calculate()
|
||||
{
|
||||
FindTargetForTankStrategy strategy(botAI);
|
||||
// FindTargetForTankStrategy strategy(botAI);
|
||||
FindTankTargetSmartStrategy strategy(botAI);
|
||||
return FindTarget(&strategy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user