mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-14 09:29:09 +00:00
Estimated dps calculation
This commit is contained in:
@@ -52,7 +52,7 @@ Unit* MeleeAttackerWithoutAuraTargetValue::Calculate()
|
||||
if (!bot->IsWithinMeleeRange(unit))
|
||||
continue;
|
||||
|
||||
if (checkArc && !bot->HasInArc(CAST_ANGLE_IN_FRONT, unit))
|
||||
if (checkArc && !bot->HasInArc(M_PI, unit))
|
||||
continue;
|
||||
|
||||
if (unit->GetHealth() < max_health)
|
||||
|
||||
@@ -291,7 +291,7 @@ Unit* DpsTargetValue::Calculate()
|
||||
return rti;
|
||||
|
||||
// FindLeastHpTargetStrategy strategy(botAI);
|
||||
float dps = AI_VALUE(float, "expected group dps");
|
||||
float dps = AI_VALUE(float, "estimated group dps");
|
||||
if (botAI->IsCaster(bot))
|
||||
{
|
||||
CasterFindTargetSmartStrategy strategy(botAI, dps);
|
||||
|
||||
135
src/strategy/values/EstimatedLifetimeValue.cpp
Normal file
135
src/strategy/values/EstimatedLifetimeValue.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
#include "EstimatedLifetimeValue.h"
|
||||
|
||||
#include "AiFactory.h"
|
||||
#include "PlayerbotAI.h"
|
||||
#include "PlayerbotAIConfig.h"
|
||||
#include "Playerbots.h"
|
||||
#include "SharedDefines.h"
|
||||
|
||||
float EstimatedLifetimeValue::Calculate()
|
||||
{
|
||||
Unit* target = AI_VALUE(Unit*, qualifier);
|
||||
if (!target || !target->IsAlive())
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
float dps = AI_VALUE(float, "estimated group dps");
|
||||
bool aoePenalty = AI_VALUE(uint8, "attacker count") >= 3;
|
||||
if (aoePenalty)
|
||||
dps *= 0.75;
|
||||
float res = target->GetHealth() / dps;
|
||||
// bot->Say(target->GetName() + " lifetime: " + std::to_string(res), LANG_UNIVERSAL);
|
||||
return res;
|
||||
}
|
||||
|
||||
float EstimatedGroupDpsValue::Calculate()
|
||||
{
|
||||
float totalDps;
|
||||
|
||||
std::vector<Player*> groupPlayer={bot};
|
||||
if (Group* group = bot->GetGroup())
|
||||
{
|
||||
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
|
||||
{
|
||||
Player* member = gref->GetSource();
|
||||
if (member == bot) // calculated
|
||||
continue;
|
||||
|
||||
if (!member || !member->IsInWorld())
|
||||
continue;
|
||||
|
||||
if (member->GetMapId() != bot->GetMapId())
|
||||
continue;
|
||||
|
||||
if (member->GetExactDist(bot) > sPlayerbotAIConfig->sightDistance)
|
||||
continue;
|
||||
|
||||
groupPlayer.push_back(member);
|
||||
}
|
||||
}
|
||||
for (Player* player : groupPlayer)
|
||||
{
|
||||
float roleMultiplier;
|
||||
if (botAI->IsTank(player))
|
||||
roleMultiplier = 0.3f;
|
||||
else if (botAI->IsHeal(player))
|
||||
roleMultiplier = 0.1f;
|
||||
else
|
||||
roleMultiplier = 1.0f;
|
||||
float basicDps = GetBasicDps(player->GetLevel());
|
||||
float basicGs = GetBasicGs(player->GetLevel());
|
||||
uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(player, true, false, 12);
|
||||
|
||||
float gap = (float)mixedGearScore / basicGs - 1;
|
||||
float gs_modifier = gap * 3 + 1;
|
||||
if (gs_modifier < 0.75)
|
||||
gs_modifier = 0.75;
|
||||
if (gs_modifier > 4)
|
||||
gs_modifier = 4;
|
||||
totalDps += basicDps * roleMultiplier * gs_modifier;
|
||||
}
|
||||
|
||||
return totalDps;
|
||||
}
|
||||
|
||||
float EstimatedGroupDpsValue::GetBasicDps(uint32 level)
|
||||
{
|
||||
float basic_dps;
|
||||
|
||||
if (level <= 15)
|
||||
{
|
||||
basic_dps = 5 + level * 1;
|
||||
}
|
||||
else if (level <= 25)
|
||||
{
|
||||
basic_dps = 20 + (level - 15) * 2;
|
||||
}
|
||||
else if (level <= 45)
|
||||
{
|
||||
basic_dps = 40 + (level - 25) * 3;
|
||||
}
|
||||
else if (level <= 55)
|
||||
{
|
||||
basic_dps = 100 + (level - 45) * 20;
|
||||
}
|
||||
else if (level <= 60)
|
||||
{
|
||||
basic_dps = 300 + (level - 55) * 50;
|
||||
}
|
||||
else if (level <= 70)
|
||||
{
|
||||
basic_dps = 450 + (level - 60) * 40;
|
||||
}
|
||||
else
|
||||
{
|
||||
basic_dps = 750 + (level - 70) * 175;
|
||||
}
|
||||
return basic_dps;
|
||||
}
|
||||
|
||||
float EstimatedGroupDpsValue::GetBasicGs(uint32 level)
|
||||
{
|
||||
float basic_gs;
|
||||
|
||||
if (level <= 8)
|
||||
{
|
||||
basic_gs = (level + 5) * 2;
|
||||
}
|
||||
else if (level <= 15)
|
||||
{
|
||||
basic_gs = (level + 5) * 3;
|
||||
}
|
||||
else if (level <= 60)
|
||||
{
|
||||
basic_gs = (level + 5) * 4;
|
||||
}
|
||||
else if (level <= 70)
|
||||
{
|
||||
basic_gs = (85 + (level - 60) * 3) * 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
basic_gs = (155 + (level - 70) * 4) * 4;
|
||||
}
|
||||
return basic_gs;
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
* and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#ifndef _PLAYERBOT_EXPECTEDLIFETIMEVALUE_H
|
||||
#define _PLAYERBOT_EXPECTEDLIFETIMEVALUE_H
|
||||
#ifndef _PLAYERBOT_EstimatedLifetimeValue_H
|
||||
#define _PLAYERBOT_EstimatedLifetimeValue_H
|
||||
|
||||
#include "NamedObjectContext.h"
|
||||
#include "PossibleTargetsValue.h"
|
||||
@@ -15,22 +15,26 @@ class PlayerbotAI;
|
||||
class Unit;
|
||||
|
||||
// [target health] / [expected group single target dps] = [expected lifetime]
|
||||
class ExpectedLifetimeValue : public FloatCalculatedValue, public Qualified
|
||||
class EstimatedLifetimeValue : public FloatCalculatedValue, public Qualified
|
||||
{
|
||||
public:
|
||||
ExpectedLifetimeValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "expected lifetime") {}
|
||||
EstimatedLifetimeValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "estimated lifetime") {}
|
||||
|
||||
public:
|
||||
float Calculate() override;
|
||||
};
|
||||
|
||||
class ExpectedGroupDpsValue : public FloatCalculatedValue
|
||||
class EstimatedGroupDpsValue : public FloatCalculatedValue
|
||||
{
|
||||
public:
|
||||
ExpectedGroupDpsValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "expected group dps", 20 * 1000) {}
|
||||
EstimatedGroupDpsValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "estimated group dps", 20 * 1000) {}
|
||||
|
||||
public:
|
||||
float Calculate() override;
|
||||
|
||||
protected:
|
||||
float GetBasicDps(uint32 level);
|
||||
float GetBasicGs(uint32 level);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,102 +0,0 @@
|
||||
#include "ExpectedLifetimeValue.h"
|
||||
|
||||
#include "AiFactory.h"
|
||||
#include "PlayerbotAI.h"
|
||||
#include "Playerbots.h"
|
||||
#include "SharedDefines.h"
|
||||
|
||||
float ExpectedLifetimeValue::Calculate()
|
||||
{
|
||||
Unit* target = AI_VALUE(Unit*, qualifier);
|
||||
if (!target || !target->IsAlive())
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
float dps = AI_VALUE(float, "expected group dps");
|
||||
bool aoePenalty = AI_VALUE(uint8, "attacker count") >= 3;
|
||||
if (aoePenalty)
|
||||
dps *= 0.75;
|
||||
float res = target->GetHealth() / dps;
|
||||
// bot->Say(target->GetName() + " lifetime: " + std::to_string(res), LANG_UNIVERSAL);
|
||||
return res;
|
||||
}
|
||||
|
||||
float ExpectedGroupDpsValue::Calculate()
|
||||
{
|
||||
float dps_num;
|
||||
Group* group = bot->GetGroup();
|
||||
if (!group)
|
||||
{
|
||||
dps_num = 0.7;
|
||||
}
|
||||
else
|
||||
{
|
||||
dps_num = botAI->GetNearGroupMemberCount() * 0.7;
|
||||
}
|
||||
uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(bot, true, false, 12);
|
||||
// efficiency record based on rare gear level, is there better calculation method?
|
||||
// float dps_efficiency = 1;
|
||||
float basic_dps;
|
||||
int32 basic_gs;
|
||||
int32 level = bot->GetLevel();
|
||||
|
||||
if (level <= 15)
|
||||
{
|
||||
basic_dps = 5 + level * 1;
|
||||
}
|
||||
else if (level <= 25)
|
||||
{
|
||||
basic_dps = 20 + (level - 15) * 2;
|
||||
}
|
||||
else if (level <= 40)
|
||||
{
|
||||
basic_dps = 40 + (level - 30) * 4;
|
||||
}
|
||||
else if (level <= 55)
|
||||
{
|
||||
basic_dps = 100 + (level - 45) * 20;
|
||||
}
|
||||
else if (level <= 60)
|
||||
{
|
||||
basic_dps = 300 + (level - 55) * 50;
|
||||
}
|
||||
else if (level <= 70)
|
||||
{
|
||||
basic_dps = 450 + (level - 60) * 40;
|
||||
}
|
||||
else
|
||||
{
|
||||
basic_dps = 750 + (level - 70) * 175;
|
||||
}
|
||||
|
||||
if (level <= 8)
|
||||
{
|
||||
basic_gs = (level + 5) * 2;
|
||||
}
|
||||
else if (level <= 15)
|
||||
{
|
||||
basic_gs = (level + 5) * 3;
|
||||
}
|
||||
else if (level <= 60)
|
||||
{
|
||||
basic_gs = (level + 5) * 4;
|
||||
}
|
||||
else if (level <= 70)
|
||||
{
|
||||
basic_gs = (85 + (level - 60) * 3) * 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
basic_gs = (155 + (level - 70) * 4) * 4;
|
||||
}
|
||||
float gap = mixedGearScore - basic_gs;
|
||||
float gs_modifier = (float)mixedGearScore / basic_gs - 1;
|
||||
gs_modifier = gs_modifier * 3 + 1;
|
||||
|
||||
if (gs_modifier < 0.75)
|
||||
gs_modifier = 0.75;
|
||||
if (gs_modifier > 4)
|
||||
gs_modifier = 4;
|
||||
|
||||
return dps_num * basic_dps * gs_modifier;
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "DuelTargetValue.h"
|
||||
#include "EnemyHealerTargetValue.h"
|
||||
#include "EnemyPlayerValue.h"
|
||||
#include "ExpectedLifetimeValue.h"
|
||||
#include "EstimatedLifetimeValue.h"
|
||||
#include "Formations.h"
|
||||
#include "GrindTargetValue.h"
|
||||
#include "GroupValues.h"
|
||||
@@ -299,8 +299,8 @@ public:
|
||||
creators["boss target"] = &ValueContext::boss_target;
|
||||
creators["nearest triggers"] = &ValueContext::nearest_triggers;
|
||||
creators["neglect threat"] = &ValueContext::neglect_threat;
|
||||
creators["expected lifetime"] = &ValueContext::expected_lifetime;
|
||||
creators["expected group dps"] = &ValueContext::expected_group_dps;
|
||||
creators["estimated lifetime"] = &ValueContext::expected_lifetime;
|
||||
creators["estimated group dps"] = &ValueContext::expected_group_dps;
|
||||
creators["area debuff"] = &ValueContext::area_debuff;
|
||||
creators["nearest trap with damage"] = &ValueContext::nearest_trap_with_damange;
|
||||
creators["disperse distance"] = &ValueContext::disperse_distance;
|
||||
@@ -538,8 +538,8 @@ private:
|
||||
static UntypedValue* boss_target(PlayerbotAI* ai) { return new BossTargetValue(ai); }
|
||||
static UntypedValue* nearest_triggers(PlayerbotAI* ai) { return new NearestTriggersValue(ai); }
|
||||
static UntypedValue* neglect_threat(PlayerbotAI* ai) { return new NeglectThreatResetValue(ai); }
|
||||
static UntypedValue* expected_lifetime(PlayerbotAI* ai) { return new ExpectedLifetimeValue(ai); }
|
||||
static UntypedValue* expected_group_dps(PlayerbotAI* ai) { return new ExpectedGroupDpsValue(ai); }
|
||||
static UntypedValue* expected_lifetime(PlayerbotAI* ai) { return new EstimatedLifetimeValue(ai); }
|
||||
static UntypedValue* expected_group_dps(PlayerbotAI* ai) { return new EstimatedGroupDpsValue(ai); }
|
||||
static UntypedValue* area_debuff(PlayerbotAI* ai) { return new AreaDebuffValue(ai); }
|
||||
static UntypedValue* nearest_trap_with_damange(PlayerbotAI* ai) { return new NearestTrapWithDamageValue(ai); }
|
||||
static UntypedValue* disperse_distance(PlayerbotAI* ai) { return new DisperseDistanceValue(ai); }
|
||||
|
||||
Reference in New Issue
Block a user