Merge branch 'liyunfan1223:master' into dedicated

This commit is contained in:
Atidote
2024-08-03 09:42:26 +02:00
committed by GitHub
8 changed files with 107 additions and 98 deletions

View File

@@ -95,11 +95,11 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
return false;
}
if (bot->IsMounted() && bot->IsWithinLOSInMap(target))
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
}
// if (bot->IsMounted() && bot->IsWithinLOSInMap(target))
// {
// WorldPacket emptyPacket;
// bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
// }
ObjectGuid guid = target->GetGUID();
bot->SetSelection(target->GetGUID());

View File

@@ -4410,11 +4410,11 @@ bool BGTactics::moveToObjective()
//std::ostringstream out; out << "Moving to objective " << pos.x << ", " << pos.y << ", Distance: " << sServerFacade->GetDistance2d(bot, pos.x, pos.y);
//bot->Say(out.str(), LANG_UNIVERSAL);
// more precise position for wsg and AV (flags in AV towers require precision)
if (bgType == BATTLEGROUND_WS || bgType == BATTLEGROUND_AV)
// more precise position for wsg
if (bgType == BATTLEGROUND_WS)
return MoveTo(bot->GetMapId(), pos.x, pos.y, pos.z);
else
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z, 3.0f);
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z, 1.5f);//note - don't make distance too large or horde bots may struggle to get flags in alliance AV towers (because they'll be targetting a spot in midair)
}
return false;
}
@@ -4774,9 +4774,9 @@ bool BGTactics::atFlag(std::vector<BattleBotPath*> const& vPaths, std::vector<ui
if (!bot->CanUseBattlegroundObject(go) && bgType != BATTLEGROUND_WS)
continue;
if (flagRange)
if (!bot->IsWithinDistInMap(go, flagRange))
continue;
float const dist = sqrt(bot->GetDistance(go));
if (flagRange && dist > flagRange)
continue;
bool atBase = bgType == BATTLEGROUND_WS ? go->GetEntry() == vFlagsWS[bot->GetTeamId()] : bgType == BATTLEGROUND_EY ? go->GetEntry() == vFlagsEY[0] : false;
@@ -4789,6 +4789,13 @@ bool BGTactics::atFlag(std::vector<BattleBotPath*> const& vPaths, std::vector<ui
case BATTLEGROUND_AB:
case BATTLEGROUND_IC:
{
if (dist == 0.0f)
{
// this is to prevent bots capping while standing INSIDE the flag pole (which can be thick enough to hide player entirely)
// note that dist is taking into account size of object and bot (it's the space between outside of both) so moveDist needs to as well
float const moveDist = bot->GetObjectSize() + go->GetObjectSize() + 0.1f;
return MoveTo(bot->GetMapId(), go->GetPositionX() + (urand(0, 1) ? -moveDist : moveDist), go->GetPositionY() + (urand(0, 1) ? -moveDist : moveDist), go->GetPositionZ());
}
if (bot->IsMounted())
bot->RemoveAurasByType(SPELL_AURA_MOUNTED);
@@ -4820,7 +4827,7 @@ bool BGTactics::atFlag(std::vector<BattleBotPath*> const& vPaths, std::vector<ui
}
case BATTLEGROUND_WS:
{
if (bot->IsWithinDistInMap(go, INTERACTION_DISTANCE))
if (dist < INTERACTION_DISTANCE)
{
if (atBase)
{
@@ -4868,7 +4875,7 @@ bool BGTactics::atFlag(std::vector<BattleBotPath*> const& vPaths, std::vector<ui
}
case BATTLEGROUND_EY:
{
if (bot->IsWithinDistInMap(go, INTERACTION_DISTANCE))
if (dist < INTERACTION_DISTANCE)
{
if (bot->IsMounted())
bot->RemoveAurasByType(SPELL_AURA_MOUNTED);

View File

@@ -5,6 +5,7 @@
#include "CheckMountStateAction.h"
#include "BattlegroundWS.h"
#include "Event.h"
#include "PlayerbotAI.h"
#include "Playerbots.h"
#include "ServerFacade.h"
#include "SpellAuraEffects.h"
@@ -20,18 +21,11 @@ bool CheckMountStateAction::Execute(Event event)
bool attackdistance = false;
bool chasedistance = false;
float attack_distance = 35.0f;
switch (bot->getClass())
{
case CLASS_WARRIOR:
case CLASS_PALADIN:
attack_distance = 10.0f;
break;
case CLASS_ROGUE:
attack_distance = 40.0f;
break;
if (PlayerbotAI::IsMelee(bot)) {
attack_distance = 10.0f;
} else {
attack_distance = 40.0f;
}
if (enemy)
attack_distance /= 2;
@@ -41,6 +35,12 @@ bool CheckMountStateAction::Execute(Event event)
chasedistance = enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && AI_VALUE2(bool, "moving", "enemy player target");
}
if (bot->IsMounted() && attackdistance) {
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
return true;
}
Player* master = GetMaster();
if (master != nullptr && !bot->InBattleground())
{
@@ -48,7 +48,7 @@ bool CheckMountStateAction::Execute(Event event)
return false;
// bool farFromMaster = sServerFacade->GetDistance2d(bot, master) > sPlayerbotAIConfig->sightDistance;
if (master->IsMounted() && !bot->IsMounted() && noattackers)
if (master->IsMounted() && !bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat() && botAI->GetState() != BOT_STATE_COMBAT)
{
return Mount();
}
@@ -72,6 +72,13 @@ bool CheckMountStateAction::Execute(Event event)
return false;
}
// For random bots
if (!bot->InBattleground() && !master) {
if (!bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat()) {
return Mount();
}
}
if (bot->InBattleground() && !attackdistance && (noattackers || fartarget) && !bot->IsInCombat() && !bot->IsMounted())
{
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS)
@@ -269,8 +276,8 @@ bool CheckMountStateAction::Mount()
if (index >= ids.size())
continue;
botAI->CastSpell(ids[index], bot);
return true;
return botAI->CastSpell(ids[index], bot);;
}
std::vector<Item*> items = AI_VALUE2(std::vector<Item*>, "inventory items", "mount");

View File

@@ -857,9 +857,16 @@ void MovementAction::UpdateMovementState()
bot->SetSwim(false);
}
if (bot->IsFlying())
bot->UpdateSpeed(MOVE_FLIGHT, true);
bool onGround = bot->GetPositionZ() < bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()) + 1.0f;
if (!bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !onGround)
{
bot->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && (!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || onGround))
{
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
}
Transport* newTransport = bot->GetMap()->GetTransportForPos(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot);
if (newTransport != bot->GetTransport())
{
@@ -874,10 +881,13 @@ void MovementAction::UpdateMovementState()
bot->StopMovingOnCurrentPos();
}
bot->SendMovementFlagUpdate();
// Temporary speed increase in group
//if (botAI->HasRealPlayerMaster())
//bot->SetSpeedRate(MOVE_RUN, 1.1f);
// if (botAI->HasRealPlayerMaster()) {
// bot->SetSpeedRate(MOVE_RUN, 1.1f);
// } else {
// bot->SetSpeedRate(MOVE_RUN, 1.0f);
// }
// check if target is not reachable (from Vmangos)
// if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() && !bot->InBattleground())
// {
@@ -1146,7 +1156,18 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance, float angle)
float MovementAction::MoveDelay(float distance)
{
return distance / bot->GetSpeed(MOVE_RUN);
float speed;
if (bot->isSwimming()) {
speed = bot->GetSpeed(MOVE_SWIM);
} else if (bot->IsFlying()) {
speed = bot->GetSpeed(MOVE_FLIGHT);
} else {
speed = bot->GetSpeed(MOVE_RUN);
}
float delay = distance / speed - sPlayerbotAIConfig->reactDistance;
if (delay < 0)
delay = 0;
return delay;
}
void MovementAction::WaitForReach(float distance)