mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-16 18:30:27 +00:00
life time check for debuff spell & cast time spell
This commit is contained in:
43
src/strategy/values/ExpectedLifetimeValue.cpp
Normal file
43
src/strategy/values/ExpectedLifetimeValue.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "ExpectedLifetimeValue.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");
|
||||
float res = target->GetHealth() / dps * 1000;
|
||||
// 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 = 1;
|
||||
} else {
|
||||
dps_num = group->GetMembersCount() * 0.7;
|
||||
}
|
||||
// efficiency record based on rare gear level, is there better calculation method?
|
||||
float dps_efficiency = 1;
|
||||
if (bot->GetLevel() < 30) {
|
||||
dps_efficiency = 1.5;
|
||||
} else if (bot->GetLevel() < 40) {
|
||||
dps_efficiency = 2;
|
||||
} else if (bot->GetLevel() < 50) {
|
||||
dps_efficiency = 3;
|
||||
} else if (bot->GetLevel() < 60) {
|
||||
dps_efficiency = 4;
|
||||
} else if (bot->GetLevel() < 70) {
|
||||
dps_efficiency = 7;
|
||||
} else if (bot->GetLevel() < 80) {
|
||||
dps_efficiency = 12;
|
||||
} else {
|
||||
dps_efficiency = 30;
|
||||
}
|
||||
return dps_num * bot->GetLevel() * dps_efficiency;
|
||||
}
|
||||
36
src/strategy/values/ExpectedLifetimeValue.h
Normal file
36
src/strategy/values/ExpectedLifetimeValue.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it 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
|
||||
|
||||
#include "NamedObjectContext.h"
|
||||
#include "TargetValue.h"
|
||||
#include "PossibleTargetsValue.h"
|
||||
#include "Value.h"
|
||||
|
||||
class PlayerbotAI;
|
||||
class Unit;
|
||||
|
||||
// [target health] / [expected group single target dps] = [expected lifetime]
|
||||
class ExpectedLifetimeValue : public FloatCalculatedValue, public Qualified
|
||||
{
|
||||
public:
|
||||
ExpectedLifetimeValue(PlayerbotAI* botAI) :
|
||||
FloatCalculatedValue(botAI, "expected lifetime") { }
|
||||
|
||||
public:
|
||||
float Calculate() override;
|
||||
};
|
||||
|
||||
class ExpectedGroupDpsValue : public FloatCalculatedValue
|
||||
{
|
||||
public:
|
||||
ExpectedGroupDpsValue(PlayerbotAI* botAI) :
|
||||
FloatCalculatedValue(botAI, "expected group dps") { }
|
||||
|
||||
public:
|
||||
float Calculate() override;
|
||||
};
|
||||
#endif
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "DistanceValue.h"
|
||||
#include "EnemyHealerTargetValue.h"
|
||||
#include "EnemyPlayerValue.h"
|
||||
#include "ExpectedLifetimeValue.h"
|
||||
#include "Formations.h"
|
||||
#include "GroupValues.h"
|
||||
#include "GrindTargetValue.h"
|
||||
@@ -293,6 +294,8 @@ class ValueContext : public NamedObjectContext<UntypedValue>
|
||||
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;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -490,6 +493,9 @@ class ValueContext : public NamedObjectContext<UntypedValue>
|
||||
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); }
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user