mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-29 16:33:46 +00:00
Enable new rpg strategy by default (#1192)
* Add RandomBotMinLevelChance * Save mana only for healer * Disable addclass dk for low level player * Target selection and debuff cast with less players in group * Change default rpg strategy and bots count in config * Logs clean up * Improve init=auto * Remove login logs after initialization * Rndbots stats for quest * Prediction chase in reach combat * Poor & Normal items ensurence for init=auto
This commit is contained in:
@@ -8,6 +8,17 @@
|
||||
#include "CreatureAI.h"
|
||||
#include "Playerbots.h"
|
||||
|
||||
enum PetSpells
|
||||
{
|
||||
PET_PROWL_1 = 24450,
|
||||
PET_PROWL_2 = 24452,
|
||||
PET_PROWL_3 = 24453,
|
||||
PET_COWER = 1742,
|
||||
PET_LEAP = 47482
|
||||
};
|
||||
|
||||
static std::vector<uint32> disabledPetSpells = {PET_PROWL_1, PET_PROWL_2, PET_PROWL_3, PET_COWER, PET_LEAP};
|
||||
|
||||
bool MeleeAction::isUseful()
|
||||
{
|
||||
// do not allow if can't attack from vehicle
|
||||
@@ -44,18 +55,20 @@ bool TogglePetSpellAutoCastAction::Execute(Event event)
|
||||
{
|
||||
if (itr->second.state == PETSPELL_REMOVED)
|
||||
continue;
|
||||
|
||||
|
||||
uint32 spellId = itr->first;
|
||||
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo->IsAutocastable())
|
||||
continue;
|
||||
|
||||
bool shouldApply = true;
|
||||
if (spellId == 1742 /*cower*/ || spellId == 24450 /*Prowl*/ ||
|
||||
spellId == 47482 /*Leap*/ /* || spellId == 47481 Gnaw*/)
|
||||
for (uint32 disabledSpell : disabledPetSpells)
|
||||
{
|
||||
|
||||
shouldApply = false;
|
||||
if (spellId == disabledSpell)
|
||||
{
|
||||
shouldApply = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool isAutoCast = false;
|
||||
for (unsigned int& m_autospell : pet->m_autospells)
|
||||
|
||||
@@ -847,6 +847,26 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
||||
float tx = target->GetPositionX();
|
||||
float ty = target->GetPositionY();
|
||||
float tz = target->GetPositionZ();
|
||||
|
||||
float targetOrientation = target->GetOrientation();
|
||||
|
||||
float deltaAngle = Position::NormalizeOrientation(targetOrientation - target->GetAngle(bot));
|
||||
if (deltaAngle > M_PI)
|
||||
deltaAngle -= 2.0f * M_PI; // -PI..PI
|
||||
// if target is moving forward and moving far away, predict the position
|
||||
bool behind = fabs(deltaAngle) > M_PI_2;
|
||||
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD) && behind) {
|
||||
float predictDis = std::min(3.0f, target->GetObjectSize() * 2);
|
||||
tx += cos(target->GetOrientation()) * predictDis;
|
||||
ty += sin(target->GetOrientation()) * predictDis;
|
||||
if (!target->GetMap()->CheckCollisionAndGetValidCoords(target, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),
|
||||
tx, ty, tz))
|
||||
{
|
||||
tx = target->GetPositionX();
|
||||
ty = target->GetPositionY();
|
||||
tz = target->GetPositionZ();
|
||||
}
|
||||
}
|
||||
float combatDistance = bot->GetCombatReach() + target->GetCombatReach();
|
||||
distance += combatDistance;
|
||||
|
||||
@@ -863,7 +883,7 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
||||
|
||||
// Avoid walking too far when moving towards each other
|
||||
float disToGo = bot->GetExactDist(tx, ty, tz) - distance;
|
||||
if (disToGo >= 10.0f)
|
||||
if (disToGo >= 6.0f)
|
||||
shortenTo = disToGo / 2 + distance;
|
||||
|
||||
// if (bot->GetExactDist(tx, ty, tz) <= shortenTo)
|
||||
|
||||
@@ -79,7 +79,8 @@ void FrostMageStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", ACTION_HIGH + 1), nullptr)));
|
||||
triggers.push_back(
|
||||
new TriggerNode("medium health", NextAction::array(0, new NextAction("ice barrier", ACTION_NORMAL), nullptr)));
|
||||
|
||||
triggers.push_back(
|
||||
new TriggerNode("being attacked", NextAction::array(0, new NextAction("ice barrier", ACTION_HIGH + 1), nullptr)));
|
||||
triggers.push_back(new TriggerNode(
|
||||
"brain freeze", NextAction::array(0, new NextAction("frostfire bolt", ACTION_NORMAL + 3), nullptr)));
|
||||
// Combo cast the last charge of fingers of frost for double crits.
|
||||
|
||||
@@ -56,6 +56,8 @@ void GenericPriestStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
|
||||
triggers.push_back(new TriggerNode("enemy too close for spell",
|
||||
NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr)));
|
||||
triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr)));
|
||||
triggers.push_back(new TriggerNode("being attacked",
|
||||
NextAction::array(0, new NextAction("power word: shield", ACTION_HIGH + 1), nullptr)));
|
||||
}
|
||||
|
||||
PriestCureStrategy::PriestCureStrategy(PlayerbotAI* botAI) : Strategy(botAI)
|
||||
|
||||
@@ -135,11 +135,11 @@ protected:
|
||||
float targetExpectedLifeTime;
|
||||
};
|
||||
|
||||
// non caster
|
||||
class NonCasterFindTargetSmartStrategy : public FindTargetStrategy
|
||||
// General
|
||||
class GeneralFindTargetSmartStrategy : public FindTargetStrategy
|
||||
{
|
||||
public:
|
||||
NonCasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps)
|
||||
GeneralFindTargetSmartStrategy(PlayerbotAI* botAI, float dps)
|
||||
: FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000)
|
||||
{
|
||||
}
|
||||
@@ -178,7 +178,6 @@ public:
|
||||
{
|
||||
float new_time = new_unit->GetHealth() / dps_;
|
||||
float old_time = old_unit->GetHealth() / dps_;
|
||||
// [5-20] > (5-0] > (20-inf)
|
||||
int new_level = GetIntervalLevel(new_unit);
|
||||
int old_level = GetIntervalLevel(old_unit);
|
||||
if (new_level != old_level)
|
||||
@@ -297,20 +296,24 @@ Unit* DpsTargetValue::Calculate()
|
||||
if (rti)
|
||||
return rti;
|
||||
|
||||
// FindLeastHpTargetStrategy strategy(botAI);
|
||||
Group* group = bot->GetGroup();
|
||||
float dps = AI_VALUE(float, "estimated group dps");
|
||||
if (group && botAI->IsCaster(bot))
|
||||
|
||||
if (botAI->GetNearGroupMemberCount() > 3)
|
||||
{
|
||||
CasterFindTargetSmartStrategy strategy(botAI, dps);
|
||||
return TargetValue::FindTarget(&strategy);
|
||||
if (botAI->IsCaster(bot))
|
||||
{
|
||||
// Caster find target strategy avoids casting spells on enemies
|
||||
// with too low health to ensure the effectiveness of casting
|
||||
CasterFindTargetSmartStrategy strategy(botAI, dps);
|
||||
return TargetValue::FindTarget(&strategy);
|
||||
}
|
||||
else if (botAI->IsCombo(bot))
|
||||
{
|
||||
ComboFindTargetSmartStrategy strategy(botAI, dps);
|
||||
return TargetValue::FindTarget(&strategy);
|
||||
}
|
||||
}
|
||||
else if (botAI->IsCombo(bot))
|
||||
{
|
||||
ComboFindTargetSmartStrategy strategy(botAI, dps);
|
||||
return TargetValue::FindTarget(&strategy);
|
||||
}
|
||||
NonCasterFindTargetSmartStrategy strategy(botAI, dps);
|
||||
GeneralFindTargetSmartStrategy strategy(botAI, dps);
|
||||
return TargetValue::FindTarget(&strategy);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ float EstimatedGroupDpsValue::Calculate()
|
||||
if (member == bot) // calculated
|
||||
continue;
|
||||
|
||||
// ignore real player as they may not help with damage
|
||||
if (!GET_PLAYERBOT_AI(member) || GET_PLAYERBOT_AI(member)->IsRealPlayer())
|
||||
continue;
|
||||
|
||||
if (!member || !member->IsInWorld() || !member->IsAlive())
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user