mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-18 01:24:35 +00:00
fix: bot stuck after drink or food && initialization customized
This commit is contained in:
@@ -643,7 +643,7 @@ void Engine::LogAction(char const* format, ...)
|
||||
if (sPlayerbotAIConfig->logInGroupOnly && !bot->GetGroup())
|
||||
return;
|
||||
|
||||
LOG_INFO("playerbots", "{} {} {} {}", bot->GetName().c_str(), buf, sPlayerbotAIConfig->logInGroupOnly, bot->GetGroup()->GetGroupType());
|
||||
LOG_DEBUG("playerbots", "{} {}", bot->GetName().c_str(), buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ bool ChooseRpgTargetAction::Execute(Event event)
|
||||
|
||||
if (targets.empty())
|
||||
{
|
||||
LOG_INFO("playerbots", "{} can't choose RPG target: all {} are not available", bot->GetName().c_str(), possibleTargets.size());
|
||||
LOG_DEBUG("playerbots", "{} can't choose RPG target: all {} are not available", bot->GetName().c_str(), possibleTargets.size());
|
||||
RESET_AI_VALUE(GuidSet&, "ignore rpg target");
|
||||
RESET_AI_VALUE(GuidPosition, "rpg target");
|
||||
return false;
|
||||
|
||||
@@ -23,7 +23,7 @@ bool FollowAction::Execute(Event event)
|
||||
WorldLocation loc = formation->GetLocation();
|
||||
if (Formation::IsNullLocation(loc) || loc.GetMapId() == -1)
|
||||
return false;
|
||||
|
||||
|
||||
moved = MoveTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged)
|
||||
bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bool react)
|
||||
{
|
||||
UpdateMovementState();
|
||||
|
||||
LOG_DEBUG("playerbots", "IsMovingAllowed {}", IsMovingAllowed());
|
||||
if (!IsMovingAllowed())
|
||||
return false;
|
||||
|
||||
@@ -137,6 +137,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
if (Vehicle* vehicle = bot->GetVehicle())
|
||||
{
|
||||
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
||||
LOG_DEBUG("playerbots", "!seat || !seat->CanControl() {}", !seat || !seat->CanControl());
|
||||
if (!seat || !seat->CanControl())
|
||||
return false;
|
||||
|
||||
@@ -150,6 +151,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
time_t now = time(nullptr);
|
||||
if (AI_VALUE(LastMovement&, "last movement").nextTeleport > now) // We can not teleport yet. Wait.
|
||||
{
|
||||
LOG_DEBUG("playerbots", "AI_VALUE(LastMovement&, \"last movement\").nextTeleport > now");
|
||||
botAI->SetNextCheckDelay((AI_VALUE(LastMovement&, "last movement").nextTeleport - now) * 1000);
|
||||
return true;
|
||||
}
|
||||
@@ -169,6 +171,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
if (!isVehicle && !IsMovingAllowed() && bot->isDead())
|
||||
{
|
||||
bot->StopMoving();
|
||||
LOG_DEBUG("playerbots", "!isVehicle && !IsMovingAllowed() && bot->isDead()");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,6 +179,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
{
|
||||
if (!bot->HasUnitState(UNIT_STATE_IN_FLIGHT))
|
||||
bot->StopMoving();
|
||||
LOG_DEBUG("playerbots", "!isVehicle && bot->isMoving() && !IsMovingAllowed()");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -194,6 +198,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
AI_VALUE(LastMovement&, "last movement").clear();
|
||||
|
||||
mover->StopMoving();
|
||||
LOG_DEBUG("playerbots", "totalDistance < minDist");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -222,6 +227,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
else
|
||||
{
|
||||
lastMove.future = std::async(&TravelNodeMap::getFullPath, startPosition, endPosition, bot);
|
||||
LOG_DEBUG("playerbots", "lastMove.future = std::async(&TravelNodeMap::getFullPath, startPosition, endPosition, bot);");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -240,6 +246,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
bot->StopMoving();
|
||||
if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
||||
botAI->TellMasterNoFacing("I have no path");
|
||||
LOG_DEBUG("playerbots", "sServerFacade->IsDistanceGreaterThan(totalDistance, maxDist * 3)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -276,7 +283,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
|
||||
if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
||||
botAI->TellMasterNoFacing("Too far from path. Rebuilding.");
|
||||
|
||||
LOG_DEBUG("playerbots", "movePath.empty()");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -318,8 +325,10 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
{
|
||||
AI_VALUE(LastMovement&, "last area trigger").lastAreaTrigger = entry;
|
||||
}
|
||||
else
|
||||
else {
|
||||
LOG_DEBUG("playerbots", "!entry");
|
||||
return bot->TeleportTo(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), movePosition.getZ(), movePosition.getO(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (pathType == TravelNodePathType::transport && entry)
|
||||
@@ -331,6 +340,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
transport->AddPassenger(bot, true);
|
||||
}
|
||||
WaitForReach(100.0f);
|
||||
LOG_DEBUG("playerbots", "pathType == TravelNodePathType::transport && entry");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -367,7 +377,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
{
|
||||
bot->SetMoney(botMoney);
|
||||
}
|
||||
|
||||
LOG_DEBUG("playerbots", "goTaxi");
|
||||
return goTaxi;
|
||||
}
|
||||
}
|
||||
@@ -384,6 +394,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
{
|
||||
movePath.clear();
|
||||
AI_VALUE(LastMovement&, "last movement").setPath(movePath);
|
||||
LOG_DEBUG("playerbots", "bot->HasSpellCooldown(8690)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -402,6 +413,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
|
||||
if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
||||
botAI->TellMasterNoFacing("No point. Rebuilding.");
|
||||
LOG_DEBUG("playerbots", "!movePosition || movePosition.getMapId() != bot->GetMapId()");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -465,7 +477,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
|
||||
sPlayerbotAIConfig->log("bot_movement.csv", out.str().c_str());
|
||||
}
|
||||
|
||||
LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.getX(), startPosition.getY(), movePosition.getX(), movePosition.getY());
|
||||
if (!react)
|
||||
if (totalDistance > maxDist)
|
||||
WaitForReach(startPosition.distance(movePosition) - 10.0f);
|
||||
@@ -514,7 +526,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
time_t now = time(nullptr);
|
||||
|
||||
AI_VALUE(LastMovement&, "last movement").nextTeleport = now + (time_t)MoveDelay(startPosition.distance(movePosition));
|
||||
|
||||
LOG_DEBUG("playerbots", "totalDistance > maxDist && !detailedMove && !botAI->HasPlayerNearby(&movePosition)");
|
||||
return bot->TeleportTo(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), movePosition.getZ(), startPosition.getAngleTo(movePosition));
|
||||
}
|
||||
|
||||
@@ -530,11 +542,13 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
bot->SetWalk(true);
|
||||
|
||||
bot->SendMovementFlagUpdate();
|
||||
|
||||
LOG_DEBUG("playerbots", "normal move? {} {} {}", !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY),
|
||||
bot->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE), bot->getStandState());
|
||||
if (!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY))
|
||||
{
|
||||
bot->SetWalk(masterWalking);
|
||||
bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), movePosition.getZ(), generatePath);
|
||||
LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -580,6 +594,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
}
|
||||
|
||||
bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), Position(movePosition.getX(), movePosition.getY(), movePosition.getZ(), 0.f));
|
||||
LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY());
|
||||
}
|
||||
|
||||
AI_VALUE(LastMovement&, "last movement").setShort(movePosition);
|
||||
@@ -587,6 +602,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
if (!idle)
|
||||
ClearIdleState();
|
||||
|
||||
LOG_DEBUG("playerbots", "return true in the end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -990,8 +1006,9 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance, float angle)
|
||||
botAI->InterruptSpell();
|
||||
}
|
||||
|
||||
bot->GetMotionMaster()->Clear();
|
||||
// bot->GetMotionMaster()->Clear();
|
||||
bot->GetMotionMaster()->MoveChase((Unit*) obj, distance, angle);
|
||||
WaitForReach(bot->GetExactDist2d(obj) - distance);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ bool DrinkAction::Execute(Event event)
|
||||
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->AddUnitState(UNIT_STAND_STATE_SIT);
|
||||
bot->SetStandState(UNIT_STAND_STATE_SIT);
|
||||
botAI->InterruptSpell();
|
||||
|
||||
//float hp = bot->GetHealthPercent();
|
||||
@@ -82,7 +81,7 @@ bool EatAction::Execute(Event event)
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->AddUnitState(UNIT_STAND_STATE_SIT);
|
||||
bot->SetStandState(UNIT_STAND_STATE_SIT);
|
||||
botAI->InterruptSpell();
|
||||
|
||||
float hp = bot->GetHealthPct();
|
||||
|
||||
@@ -124,7 +124,7 @@ bool AutoReleaseSpiritAction::isUseful()
|
||||
|
||||
bool RepopAction::Execute(Event event)
|
||||
{
|
||||
LOG_INFO("playerbots", "Bot {} {}:{} <{}> repops at graveyard", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->getLevel(), bot->GetName().c_str());
|
||||
LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> repops at graveyard", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->getLevel(), bot->GetName().c_str());
|
||||
|
||||
int64 deadTime;
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
|
||||
if (bot->IsInCombat())
|
||||
return false;
|
||||
|
||||
bot->AddUnitState(UNIT_STAND_STATE_SIT);
|
||||
bot->SetStandState(UNIT_STAND_STATE_SIT);
|
||||
botAI->InterruptSpell();
|
||||
|
||||
float hp = bot->GetHealthPct();
|
||||
|
||||
@@ -53,13 +53,13 @@ bool HunterHasAmmoTrigger::IsActive()
|
||||
bool SwitchToRangedTrigger::IsActive()
|
||||
{
|
||||
Unit* target = AI_VALUE(Unit*, "current target");
|
||||
return botAI->HasStrategy("close", BOT_STATE_COMBAT) && target && (target->GetVictim() != bot ||
|
||||
return botAI->HasStrategy("close", BOT_STATE_COMBAT) && target && (target->GetVictim() != bot &&
|
||||
sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f));
|
||||
}
|
||||
|
||||
bool SwitchToMeleeTrigger::IsActive()
|
||||
{
|
||||
Unit* target = AI_VALUE(Unit*, "current target");
|
||||
return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && target && (target->GetVictim() == bot ||
|
||||
return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && target && (target->GetVictim() == bot &&
|
||||
sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f));
|
||||
}
|
||||
|
||||
@@ -135,9 +135,10 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
|
||||
|
||||
bool AttackersValue::IsValidTarget(Unit *attacker, Player *bot)
|
||||
{
|
||||
return IsPossibleTarget(attacker, bot) && (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
|
||||
return IsPossibleTarget(attacker, bot) && (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
|
||||
attacker->GetGUID().IsPlayer() || attacker->GetGUID() == GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<ObjectGuid>("pull target")->Get());
|
||||
}
|
||||
|
||||
bool PossibleAddsValue::Calculate()
|
||||
{
|
||||
GuidVector possible = botAI->GetAiObjectContext()->GetValue<GuidVector >("possible targets no los")->Get();
|
||||
|
||||
@@ -16,7 +16,7 @@ class Unit;
|
||||
class AttackersValue : public ObjectGuidListCalculatedValue
|
||||
{
|
||||
public:
|
||||
AttackersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "attackers", 2) { }
|
||||
AttackersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "attackers", 1) { }
|
||||
|
||||
GuidVector Calculate();
|
||||
static bool IsPossibleTarget(Unit* attacker, Player* bot, float range = sPlayerbotAIConfig->sightDistance);
|
||||
|
||||
@@ -15,7 +15,15 @@ bool InvalidTargetValue::Calculate()
|
||||
|
||||
if (target && qualifier == "current target")
|
||||
{
|
||||
return !AttackersValue::IsValidTarget(target, bot);
|
||||
return target->GetMapId() != bot->GetMapId() ||
|
||||
!target->IsAlive() ||
|
||||
target->IsPolymorphed() ||
|
||||
target->IsCharmed() ||
|
||||
target->isFeared() ||
|
||||
target->HasUnitState(UNIT_STATE_ISOLATED) ||
|
||||
target->IsFriendlyTo(bot) ||
|
||||
!bot->IsWithinDistInMap(target, sPlayerbotAIConfig->sightDistance) ||
|
||||
!bot->IsWithinLOSInMap(target);
|
||||
}
|
||||
|
||||
return !target;
|
||||
|
||||
Reference in New Issue
Block a user