From 6b8e906e3929121d8472a4bae0be9b0704058c28 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 1 Jan 2025 20:40:39 +0800 Subject: [PATCH 1/5] Fix LFG leave group --- src/PlayerbotAI.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index eb5e9c29..07aea077 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -392,7 +392,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) } } - if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && bot->GetGroup()) + if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && bot->GetGroup() && !bot->GetGroup()->isLFGGroup()) { Player* leader = bot->GetGroup()->GetLeader(); if (leader && leader != bot) // Checks if the leader is valid and is not the bot itself @@ -1312,11 +1312,9 @@ void PlayerbotAI::DoNextAction(bool min) // if in combat but stick with old data - clear targets if (currentEngine == engines[BOT_STATE_NON_COMBAT] && bot->IsInCombat()) { - if (aiObjectContext->GetValue("current target")->Get() != nullptr || - aiObjectContext->GetValue("pull target")->Get() != ObjectGuid::Empty || - aiObjectContext->GetValue("dps target")->Get() != nullptr) + if (aiObjectContext->GetValue("current target")->Get() != nullptr) { - Reset(); + aiObjectContext->GetValue("current target")->Set(nullptr); } } From 3b7415e8190d04010e2beea8aee8fe23d51ef83b Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 1 Jan 2025 20:40:48 +0800 Subject: [PATCH 2/5] Shaman totems enhancement --- src/strategy/shaman/ShamanActions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/shaman/ShamanActions.cpp b/src/strategy/shaman/ShamanActions.cpp index 9ce29240..95426d24 100644 --- a/src/strategy/shaman/ShamanActions.cpp +++ b/src/strategy/shaman/ShamanActions.cpp @@ -10,7 +10,7 @@ bool CastTotemAction::isUseful() { - if (needLifeTime > 0.1f) + if (needLifeTime > 0.1f && AI_VALUE(uint8, "attacker count") < 3) { Unit* target = AI_VALUE(Unit*, "current target"); if (!target) From da1c3effb75113a1dbfbb1038b3d54fcf219f6e3 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 1 Jan 2025 20:41:08 +0800 Subject: [PATCH 3/5] Fix movement after spell cast --- src/strategy/actions/MovementActions.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 7931de2b..a637829c 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -236,11 +236,11 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, if (bot->IsSitState()) bot->SetStandState(UNIT_STAND_STATE_STAND); - if (bot->IsNonMeleeSpellCast(true)) - { - bot->CastStop(); - botAI->InterruptSpell(); - } + // if (bot->IsNonMeleeSpellCast(true)) + // { + // bot->CastStop(); + // botAI->InterruptSpell(); + // } MotionMaster& mm = *bot->GetMotionMaster(); mm.Clear(); if (!backwards) @@ -277,11 +277,11 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, if (bot->IsSitState()) bot->SetStandState(UNIT_STAND_STATE_STAND); - if (bot->IsNonMeleeSpellCast(true)) - { - bot->CastStop(); - botAI->InterruptSpell(); - } + // if (bot->IsNonMeleeSpellCast(true)) + // { + // bot->CastStop(); + // botAI->InterruptSpell(); + // } MotionMaster& mm = *bot->GetMotionMaster(); G3D::Vector3 endP = path.back(); mm.Clear(); From 9d34a584350e925fce8471bed537aa5d0b1fdc05 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 1 Jan 2025 20:41:40 +0800 Subject: [PATCH 4/5] Improve rpg movement and grind --- src/strategy/actions/ChooseTargetActions.cpp | 24 +++++++++++--------- src/strategy/rpg/NewRpgAction.cpp | 4 ++-- src/strategy/rpg/NewRpgAction.h | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/strategy/actions/ChooseTargetActions.cpp b/src/strategy/actions/ChooseTargetActions.cpp index cc35180a..bd86740d 100644 --- a/src/strategy/actions/ChooseTargetActions.cpp +++ b/src/strategy/actions/ChooseTargetActions.cpp @@ -8,6 +8,7 @@ #include "ChooseRpgTargetAction.h" #include "Event.h" #include "LootObjectStack.h" +#include "NewRpgStrategy.h" #include "Playerbots.h" #include "PossibleRpgTargetsValue.h" #include "PvpTriggers.h" @@ -35,19 +36,24 @@ bool AttackAnythingAction::isUseful() if (!AI_VALUE(bool, "can move around")) return false; - - if (context->GetValue("travel target")->Get()->isTraveling() && - ChooseRpgTargetAction::isFollowValid( - bot, *context->GetValue("travel target")->Get()->getPosition())) // Bot is traveling - return false; - // if (bot->IsInCombat()) { + + + // if (context->GetValue("travel target")->Get()->isTraveling() && + // ChooseRpgTargetAction::isFollowValid( + // bot, *context->GetValue("travel target")->Get()->getPosition())) // Bot is traveling // return false; - // } + Unit* target = GetTarget(); if (!target) return false; + bool rpgGoStatus = botAI->rpgInfo.status == NewRpgStatus::GO_GRIND || + botAI->rpgInfo.status == NewRpgStatus::GO_INNKEEPER; + + if (rpgGoStatus && bot->GetDistance(target) > 25.0f) + return false; + std::string const name = std::string(target->GetName()); // Check for invalid targets: Dummy, Charge Target, Melee Target, Ranged Target if (!name.empty() && @@ -59,10 +65,6 @@ bool AttackAnythingAction::isUseful() return false; // Target is one of the disallowed types } - // if (!ChooseRpgTargetAction::isFollowValid(bot, target)) //Do not grind mobs far - // away from master. - // return false; - return true; } diff --git a/src/strategy/rpg/NewRpgAction.cpp b/src/strategy/rpg/NewRpgAction.cpp index ac2c7fb1..478f56fb 100644 --- a/src/strategy/rpg/NewRpgAction.cpp +++ b/src/strategy/rpg/NewRpgAction.cpp @@ -44,7 +44,7 @@ bool NewRpgStatusUpdateAction::Execute(Event event) } } // IDLE -> GO_INNKEEPER - else if (bot->GetLevel() >= 6 && roll <= 45) + else if (roll <= 45) { WorldPosition pos = SelectRandomInnKeeperPos(); if (pos != WorldPosition() && bot->GetExactDist(pos) > 50.0f) @@ -245,7 +245,7 @@ bool NewRpgGoFarAwayPosAction::MoveFarTo(WorldPosition dest) while (--attempt) { float angle = bot->GetAngle(&dest); - float delta = (rand_norm() - 0.5) * M_PI * 2; + float delta = urand(1, 100) <= 75 ? (rand_norm() - 0.5) * M_PI * 0.5 : (rand_norm() - 0.5) * M_PI * 2; angle += delta; float dis = rand_norm() * pathFinderDis; float dx = x + cos(angle) * dis; diff --git a/src/strategy/rpg/NewRpgAction.h b/src/strategy/rpg/NewRpgAction.h index fb293b8e..8e590e7a 100644 --- a/src/strategy/rpg/NewRpgAction.h +++ b/src/strategy/rpg/NewRpgAction.h @@ -23,7 +23,7 @@ public: protected: // const int32 setGrindInterval = 5 * 60 * 1000; // const int32 setNpcInterval = 1 * 60 * 1000; - const int32 statusNearNpcDuration = 2 * 60 * 1000; + const int32 statusNearNpcDuration = 5 * 60 * 1000; const int32 statusNearRandomDuration = 2 * 60 * 1000; const int32 statusRestDuration = 30 * 1000; WorldPosition SelectRandomGrindPos(); From 30437bd28f4110a2e2f54b1b635547fecaa55a29 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 1 Jan 2025 21:10:05 +0800 Subject: [PATCH 5/5] Improve inactive grind status --- src/strategy/actions/ChooseTargetActions.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/strategy/actions/ChooseTargetActions.cpp b/src/strategy/actions/ChooseTargetActions.cpp index bd86740d..54813766 100644 --- a/src/strategy/actions/ChooseTargetActions.cpp +++ b/src/strategy/actions/ChooseTargetActions.cpp @@ -48,10 +48,12 @@ bool AttackAnythingAction::isUseful() if (!target) return false; - bool rpgGoStatus = botAI->rpgInfo.status == NewRpgStatus::GO_GRIND || - botAI->rpgInfo.status == NewRpgStatus::GO_INNKEEPER; + bool inactiveGrindStatus = botAI->rpgInfo.status == NewRpgStatus::GO_GRIND || + botAI->rpgInfo.status == NewRpgStatus::NEAR_NPC || + botAI->rpgInfo.status == NewRpgStatus::REST || + botAI->rpgInfo.status == NewRpgStatus::GO_INNKEEPER; - if (rpgGoStatus && bot->GetDistance(target) > 25.0f) + if (inactiveGrindStatus && bot->GetDistance(target) > 25.0f) return false; std::string const name = std::string(target->GetName());