mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-14 07:43:44 +00:00
Merge branch 'liyunfan1223:master' into clean_quest_log
This commit is contained in:
@@ -94,6 +94,7 @@ public:
|
||||
creators["avoid aoe"] = &ActionContext::avoid_aoe;
|
||||
creators["combat formation move"] = &ActionContext::combat_formation_move;
|
||||
creators["tank face"] = &ActionContext::tank_face;
|
||||
creators["rear flank"] = &ActionContext::rear_flank;
|
||||
creators["disperse set"] = &ActionContext::disperse_set;
|
||||
creators["gift of the naaru"] = &ActionContext::gift_of_the_naaru;
|
||||
creators["shoot"] = &ActionContext::shoot;
|
||||
@@ -278,6 +279,7 @@ private:
|
||||
static Action* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeAction(botAI); }
|
||||
static Action* combat_formation_move(PlayerbotAI* botAI) { return new CombatFormationMoveAction(botAI); }
|
||||
static Action* tank_face(PlayerbotAI* botAI) { return new TankFaceAction(botAI); }
|
||||
static Action* rear_flank(PlayerbotAI* botAI) { return new RearFlankAction(botAI); }
|
||||
static Action* disperse_set(PlayerbotAI* botAI) { return new DisperseSetAction(botAI); }
|
||||
static Action* gift_of_the_naaru(PlayerbotAI* botAI) { return new CastGiftOfTheNaaruAction(botAI); }
|
||||
static Action* lifeblood(PlayerbotAI* botAI) { return new CastLifeBloodAction(botAI); }
|
||||
|
||||
@@ -234,16 +234,15 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
|
||||
return false;
|
||||
|
||||
TeamId teamId = bot->GetTeamId();
|
||||
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty()
|
||||
? sPlayerbotAIConfig->diffEmpty
|
||||
: sPlayerbotAIConfig->diffWithPlayer) *
|
||||
1.1;
|
||||
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ?
|
||||
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
|
||||
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer) * 1.1;
|
||||
|
||||
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
|
||||
uint32 TeamSize = bg->GetMaxPlayersPerTeam();
|
||||
|
||||
// If performance diff is enabled, only queue if there is no lag
|
||||
if (sPlayerbotAIConfig->enablePrototypePerformanceDiff && !noLag)
|
||||
if (sPlayerbotAIConfig->botActiveAloneSmartScale && !noLag)
|
||||
return false;
|
||||
|
||||
// If the bot is in a group, only the leader can queue
|
||||
@@ -578,16 +577,15 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
|
||||
return false;
|
||||
|
||||
TeamId teamId = bot->GetTeamId();
|
||||
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty()
|
||||
? sPlayerbotAIConfig->diffEmpty
|
||||
: sPlayerbotAIConfig->diffWithPlayer) *
|
||||
1.1;
|
||||
bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ?
|
||||
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffEmpty :
|
||||
sPlayerbotAIConfig->botActiveAloneSmartScaleDiffWithPlayer) * 1.1;
|
||||
|
||||
uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2;
|
||||
uint32 TeamSize = bg->GetMaxPlayersPerTeam();
|
||||
|
||||
// If performance diff is enabled, only queue if there is no lag
|
||||
if (sPlayerbotAIConfig->enablePrototypePerformanceDiff && !noLag)
|
||||
if (sPlayerbotAIConfig->botActiveAloneSmartScale && !noLag)
|
||||
return false;
|
||||
|
||||
// If the bot is in a group, only the leader can queue
|
||||
|
||||
@@ -82,7 +82,7 @@ bool DropTargetAction::Execute(Event event)
|
||||
bot->SetTarget(ObjectGuid::Empty);
|
||||
bot->SetSelection(ObjectGuid());
|
||||
botAI->ChangeEngine(BOT_STATE_NON_COMBAT);
|
||||
botAI->InterruptSpell();
|
||||
// botAI->InterruptSpell();
|
||||
bot->AttackStop();
|
||||
|
||||
// if (Pet* pet = bot->GetPet())
|
||||
|
||||
@@ -38,7 +38,7 @@ bool TogglePetSpellAutoCastAction::Execute(Event event)
|
||||
bool shouldApply = true;
|
||||
// imp's spell, felhunte's intelligence, cat stealth
|
||||
if (spellId == 4511 || spellId == 1742 || spellId == 54424 || spellId == 57564 || spellId == 57565 ||
|
||||
spellId == 57566 || spellId == 57567 || spellId == 24450 || spellId == 53477)
|
||||
spellId == 57566 || spellId == 57567 || spellId == 24450)
|
||||
{
|
||||
shouldApply = false;
|
||||
}
|
||||
|
||||
@@ -196,8 +196,8 @@ bool CastEnchantItemAction::isPossible()
|
||||
}
|
||||
|
||||
CastHealingSpellAction::CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount,
|
||||
HealingManaEfficiency manaEfficiency)
|
||||
: CastAuraSpellAction(botAI, spell, true), estAmount(estAmount), manaEfficiency(manaEfficiency)
|
||||
HealingManaEfficiency manaEfficiency, bool isOwner)
|
||||
: CastAuraSpellAction(botAI, spell, isOwner), estAmount(estAmount), manaEfficiency(manaEfficiency)
|
||||
{
|
||||
range = botAI->GetRange("heal");
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ class CastHealingSpellAction : public CastAuraSpellAction
|
||||
{
|
||||
public:
|
||||
CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f,
|
||||
HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM);
|
||||
HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM, bool isOwner = true);
|
||||
|
||||
std::string const GetTargetName() override { return "self target"; }
|
||||
bool isUseful() override;
|
||||
@@ -177,8 +177,8 @@ class HealPartyMemberAction : public CastHealingSpellAction, public PartyMemberA
|
||||
{
|
||||
public:
|
||||
HealPartyMemberAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f,
|
||||
HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM)
|
||||
: CastHealingSpellAction(botAI, spell, estAmount, manaEfficiency), PartyMemberActionNameSupport(spell)
|
||||
HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM, bool isOwner = true)
|
||||
: CastHealingSpellAction(botAI, spell, estAmount, manaEfficiency, isOwner), PartyMemberActionNameSupport(spell)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -827,11 +827,12 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
||||
float shortenTo = distance;
|
||||
|
||||
// Avoid walking too far when moving towards each other
|
||||
if (bot->GetDistance(tx, ty, tz) >= 10.0f)
|
||||
shortenTo = std::max(distance, bot->GetDistance(tx, ty, tz) / 2);
|
||||
float disToGo = bot->GetExactDist(tx, ty, tz) - distance;
|
||||
if (disToGo >= 10.0f)
|
||||
shortenTo = disToGo / 2 + distance;
|
||||
|
||||
if (bot->GetExactDist(tx, ty, tz) <= shortenTo)
|
||||
return false;
|
||||
// if (bot->GetExactDist(tx, ty, tz) <= shortenTo)
|
||||
// return false;
|
||||
|
||||
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), shortenTo);
|
||||
G3D::Vector3 endPos = path.GetPath().back();
|
||||
@@ -2313,7 +2314,7 @@ bool TankFaceAction::Execute(Event event)
|
||||
if (!bot->GetGroup())
|
||||
return false;
|
||||
|
||||
if (!bot->IsWithinMeleeRange(target))
|
||||
if (!bot->IsWithinMeleeRange(target) || target->isMoving())
|
||||
return false;
|
||||
|
||||
if (!AI_VALUE2(bool, "has aggro", "current target"))
|
||||
@@ -2371,6 +2372,46 @@ bool TankFaceAction::Execute(Event event)
|
||||
return MoveTo(bot->GetMapId(), nearest.GetPositionX(), nearest.GetPositionY(), nearest.GetPositionZ(), false, false, false, true, MovementPriority::MOVEMENT_COMBAT);
|
||||
}
|
||||
|
||||
bool RearFlankAction::isUseful()
|
||||
{
|
||||
Unit* target = AI_VALUE(Unit*, "current target");
|
||||
if (!target) { return false; }
|
||||
|
||||
// Need to double the front angle check to account for mirrored angle.
|
||||
bool inFront = target->HasInArc(2.f * minAngle, bot);
|
||||
// Rear check does not need to double this angle as the logic is inverted
|
||||
// and we are subtracting from 2pi.
|
||||
bool inRear = !target->HasInArc((2.f * M_PI) - maxAngle, bot);
|
||||
|
||||
return inFront || inRear;
|
||||
}
|
||||
|
||||
bool RearFlankAction::Execute(Event event)
|
||||
{
|
||||
Unit* target = AI_VALUE(Unit*, "current target");
|
||||
if (!target) { return false; }
|
||||
|
||||
float angle = frand(minAngle, maxAngle);
|
||||
float baseDistance = bot->GetMeleeRange(target) * 0.5f;
|
||||
Position leftFlank = target->GetPosition();
|
||||
Position rightFlank = target->GetPosition();
|
||||
Position* destination = nullptr;
|
||||
leftFlank.RelocatePolarOffset(angle, baseDistance + distance);
|
||||
rightFlank.RelocatePolarOffset(-angle, baseDistance + distance);
|
||||
|
||||
if (bot->GetExactDist2d(leftFlank) < bot->GetExactDist2d(rightFlank))
|
||||
{
|
||||
destination = &leftFlank;
|
||||
}
|
||||
else
|
||||
{
|
||||
destination = &rightFlank;
|
||||
}
|
||||
|
||||
return MoveTo(bot->GetMapId(), destination->GetPositionX(), destination->GetPositionY(), destination->GetPositionZ(),
|
||||
false, false, false, true, MovementPriority::MOVEMENT_COMBAT);
|
||||
}
|
||||
|
||||
bool DisperseSetAction::Execute(Event event)
|
||||
{
|
||||
std::string const text = event.getParam();
|
||||
@@ -2513,7 +2554,7 @@ bool SetBehindTargetAction::Execute(Event event)
|
||||
if (target->GetVictim() == bot)
|
||||
return false;
|
||||
|
||||
if (!bot->IsWithinMeleeRange(target))
|
||||
if (!bot->IsWithinMeleeRange(target) || target->isMoving())
|
||||
return false;
|
||||
|
||||
float deltaAngle = Position::NormalizeOrientation(target->GetOrientation() - target->GetAngle(bot));
|
||||
|
||||
@@ -18,6 +18,9 @@ class Unit;
|
||||
class WorldObject;
|
||||
class Position;
|
||||
|
||||
#define ANGLE_45_DEG (static_cast<float>(M_PI) / 4.f)
|
||||
#define ANGLE_90_DEG M_PI_2
|
||||
#define ANGLE_120_DEG (2.f * static_cast<float>(M_PI) / 3.f)
|
||||
|
||||
class MovementAction : public Action
|
||||
{
|
||||
@@ -144,6 +147,27 @@ public:
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
class RearFlankAction : public MovementAction
|
||||
{
|
||||
// 90 degree minimum angle prevents any frontal cleaves/breaths and avoids parry-hasting the boss.
|
||||
// 120 degree maximum angle leaves a 120 degree symmetrical cone at the tail end which is usually enough to avoid tail swipes.
|
||||
// Some dragons or mobs may have different danger zone angles, override if needed.
|
||||
public:
|
||||
RearFlankAction(PlayerbotAI* botAI, float distance = 0.0f, float minAngle = ANGLE_90_DEG, float maxAngle = ANGLE_120_DEG)
|
||||
: MovementAction(botAI, "rear flank")
|
||||
{
|
||||
this->distance = distance;
|
||||
this->minAngle = minAngle;
|
||||
this->maxAngle = maxAngle;
|
||||
}
|
||||
|
||||
bool Execute(Event event) override;
|
||||
bool isUseful() override;
|
||||
|
||||
protected:
|
||||
float distance, minAngle, maxAngle;
|
||||
};
|
||||
|
||||
class DisperseSetAction : public Action
|
||||
{
|
||||
public:
|
||||
@@ -268,4 +292,5 @@ public:
|
||||
|
||||
bool Execute(Event event) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user