From b2c5885050d0c67ab196b55b6548cd772c5d625d Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 26 Jul 2024 13:07:31 +0800 Subject: [PATCH 01/11] [CI] CI cache --- .github/workflows/core_build.yml | 9 ++++----- .github/workflows/windows_build.yml | 10 ++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/core_build.yml b/.github/workflows/core_build.yml index fe4802e5..b0f272f7 100644 --- a/.github/workflows/core_build.yml +++ b/.github/workflows/core_build.yml @@ -50,13 +50,12 @@ jobs: path: 'modules/mod-playerbots' - name: Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: - path: | - /var/cache/apt - /var/lib/apt - key: ccache:${{ matrix.os }}:${{ github.ref }}:${{ github.sha }} + path: ${{ github.workspace }}/var/ccache + key: ccache:${{ matrix.os }}:${{ github.ref }}:${{ matrix.c_compiler }}:${{ github.sha }} restore-keys: | + ccache:${{ matrix.os }}:${{ github.ref }}:${{ matrix.c_compiler }} ccache:${{ matrix.os }}:${{ github.ref }} ccache:${{ matrix.os }} diff --git a/.github/workflows/windows_build.yml b/.github/workflows/windows_build.yml index d6829895..48d33ba2 100644 --- a/.github/workflows/windows_build.yml +++ b/.github/workflows/windows_build.yml @@ -26,14 +26,8 @@ jobs: with: repository: 'liyunfan1223/mod-playerbots' path: 'modules/mod-playerbots' - - name: Cache - uses: actions/cache@v3 - with: - path: C:\ProgramData\chocolatey\cache - key: ccache:${{ matrix.os }}:${{ github.ref }}:${{ github.sha }} - restore-keys: | - ccache:${{ matrix.os }}:${{ github.ref }} - ccache:${{ matrix.os }} + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2.13 - name: Configure OS shell: bash env: From 278a48260f7067edaa67f73e8ce59a739ce53303 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 26 Jul 2024 15:00:37 +0800 Subject: [PATCH 02/11] [CI] core_build key order --- .github/workflows/core_build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/core_build.yml b/.github/workflows/core_build.yml index b0f272f7..806ee7df 100644 --- a/.github/workflows/core_build.yml +++ b/.github/workflows/core_build.yml @@ -53,10 +53,10 @@ jobs: uses: actions/cache@v4 with: path: ${{ github.workspace }}/var/ccache - key: ccache:${{ matrix.os }}:${{ github.ref }}:${{ matrix.c_compiler }}:${{ github.sha }} + key: ccache:${{ matrix.os }}:${{ matrix.c_compiler }}:${{ github.ref }}:${{ github.sha }} restore-keys: | - ccache:${{ matrix.os }}:${{ github.ref }}:${{ matrix.c_compiler }} - ccache:${{ matrix.os }}:${{ github.ref }} + ccache:${{ matrix.os }}:${{ matrix.c_compiler }}:${{ github.ref }} + ccache:${{ matrix.os }}:${{ matrix.c_compiler }} ccache:${{ matrix.os }} - name: Install Requirements From d78eb72b67d142d26ba99dc46ec3e68730d7f194 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 26 Jul 2024 17:17:05 +0800 Subject: [PATCH 03/11] [CI] ccache for linux build --- .github/workflows/core_build.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/core_build.yml b/.github/workflows/core_build.yml index 806ee7df..45de9b47 100644 --- a/.github/workflows/core_build.yml +++ b/.github/workflows/core_build.yml @@ -60,7 +60,25 @@ jobs: ccache:${{ matrix.os }} - name: Install Requirements - run: sudo apt-get update && sudo apt-get install git cmake make gcc g++ clang libmysqlclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev mysql-server libboost-all-dev + run: sudo apt-get update && sudo apt-get install ccache git cmake make gcc g++ clang libmysqlclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev mysql-server libboost-all-dev + + - name: setup ccache + shell: bash + env: + CCACHE_DIR: $GITHUB_WORKSPACE/var/ccache + run: | + cat <> $GITHUB_ENV + CCACHE_DIR=${{ env.CCACHE_DIR }} + CCACHE_MAXSIZE=1000MB + CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_mtime + CCACHE_CPP2=true + CCACHE_COMPRESS=1 + CCACHE_COMPRESSLEVEL=9 + CCACHE_COMPILERCHECK=content + CCACHE_LOGFILE=$CCACHE_DIR/cache.debug + CC=${{ inputs.CC }} + CXX=${{ inputs.CXX }} + EOF - name: Configure CMake run: > @@ -68,6 +86,8 @@ jobs: -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" + -DCMAKE_C_COMPILER_LAUNCHER="ccache" -S ${{ github.workspace }} - name: Build From c48d69a802f46ad7320229c384e182f79d050294 Mon Sep 17 00:00:00 2001 From: Atidot3 Date: Sat, 27 Jul 2024 10:33:49 +0200 Subject: [PATCH 04/11] Fix shaman cure strategy --- src/strategy/shaman/ShamanActions.h | 30 +++---------------- src/strategy/shaman/ShamanAiObjectContext.cpp | 16 +++++----- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/strategy/shaman/ShamanActions.h b/src/strategy/shaman/ShamanActions.h index 2db469fb..1b8d0101 100644 --- a/src/strategy/shaman/ShamanActions.h +++ b/src/strategy/shaman/ShamanActions.h @@ -5,9 +5,7 @@ #ifndef _PLAYERBOT_SHAMANACTIONS_H #define _PLAYERBOT_SHAMANACTIONS_H -#include "Define.h" #include "GenericSpellActions.h" -#include "Playerbots.h" #include "SharedDefines.h" class PlayerbotAI; @@ -362,31 +360,11 @@ class CastWindShearOnEnemyHealerAction : public CastSpellOnEnemyHealerAction CastWindShearOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "wind shear") { } }; -// class CastCurePoisonAction : public CastCureSpellAction -// { -// public: -// CastCurePoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cure poison") { } -// }; +CURE_ACTION(CastCurePoisonActionSham, "cure disease"); +CURE_PARTY_ACTION(CastCurePoisonOnPartyActionSham, "cure poison", DISPEL_POISON); -// class CastCurePoisonOnPartyAction : public CurePartyMemberAction -// { -// public: -// CastCurePoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cure poison", DISPEL_POISON) { } -// }; - -// class CastCureDiseaseAction : public CastCureSpellAction -// { -// public: -// CastCureDiseaseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cure disease") { } -// }; - -// class CastCureDiseaseOnPartyAction : public CurePartyMemberAction -// { -// public: -// CastCureDiseaseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cure disease", DISPEL_DISEASE) { } - -// std::string const getName() override { return "cure disease on party"; } -// }; +CURE_ACTION(CastCureDiseaseActionSham, "cure disease"); +CURE_PARTY_ACTION(CastCureDiseaseOnPartyActionSham, "cure disease", DISPEL_DISEASE); class CastLavaBurstAction : public CastSpellAction { diff --git a/src/strategy/shaman/ShamanAiObjectContext.cpp b/src/strategy/shaman/ShamanAiObjectContext.cpp index cee208c2..f7ac2223 100644 --- a/src/strategy/shaman/ShamanAiObjectContext.cpp +++ b/src/strategy/shaman/ShamanAiObjectContext.cpp @@ -213,10 +213,10 @@ class ShamanAiObjectContextInternal : public NamedObjectContext creators["heroism"] = &ShamanAiObjectContextInternal::heroism; creators["bloodlust"] = &ShamanAiObjectContextInternal::bloodlust; creators["elemental mastery"] = &ShamanAiObjectContextInternal::elemental_mastery; - // creators["cure disease"] = &ShamanAiObjectContextInternal::cure_disease; - // creators["cure disease on party"] = &ShamanAiObjectContextInternal::cure_disease_on_party; - // creators["cure poison"] = &ShamanAiObjectContextInternal::cure_poison; - // creators["cure poison on party"] = &ShamanAiObjectContextInternal::cure_poison_on_party; + creators["cure disease"] = &ShamanAiObjectContextInternal::cure_disease; + creators["cure disease on party"] = &ShamanAiObjectContextInternal::cure_disease_on_party; + creators["cure poison"] = &ShamanAiObjectContextInternal::cure_poison; + creators["cure poison on party"] = &ShamanAiObjectContextInternal::cure_poison_on_party; creators["lava burst"] = &ShamanAiObjectContextInternal::lava_burst; creators["earth shield on main tank"] = &ShamanAiObjectContextInternal::earth_shield_on_main_tank; creators["fire elemental totem"] = &ShamanAiObjectContextInternal::fire_elemental_totem; @@ -277,10 +277,10 @@ class ShamanAiObjectContextInternal : public NamedObjectContext static Action* lava_lash(PlayerbotAI* botAI) { return new CastLavaLashAction(botAI); } static Action* ancestral_spirit(PlayerbotAI* botAI) { return new CastAncestralSpiritAction(botAI); } static Action* wind_shear_on_enemy_healer(PlayerbotAI* botAI) { return new CastWindShearOnEnemyHealerAction(botAI); } - // static Action* cure_poison(PlayerbotAI* botAI) { return new CastCurePoisonAction(botAI); } - // static Action* cure_poison_on_party(PlayerbotAI* botAI) { return new CastCurePoisonOnPartyAction(botAI); } - // static Action* cure_disease(PlayerbotAI* botAI) { return new CastCureDiseaseAction(botAI); } - // static Action* cure_disease_on_party(PlayerbotAI* botAI) { return new CastCureDiseaseOnPartyAction(botAI); } + static Action* cure_poison(PlayerbotAI* botAI) { return new CastCurePoisonActionSham(botAI); } + static Action* cure_poison_on_party(PlayerbotAI* botAI) { return new CastCurePoisonOnPartyActionSham(botAI); } + static Action* cure_disease(PlayerbotAI* botAI) { return new CastCureDiseaseActionSham(botAI); } + static Action* cure_disease_on_party(PlayerbotAI* botAI) { return new CastCureDiseaseOnPartyActionSham(botAI); } static Action* lava_burst(PlayerbotAI* ai) { return new CastLavaBurstAction(ai); } static Action* earth_shield_on_main_tank(PlayerbotAI* ai) { return new CastEarthShieldOnMainTankAction(ai); } static Action* totem_of_wrath(PlayerbotAI* ai) { return new CastTotemOfWrathAction(ai); } From e6a7d7cc26d0c9aa53ff8f885c03ac1d6c28ef1a Mon Sep 17 00:00:00 2001 From: Atidot3 Date: Sun, 28 Jul 2024 00:54:37 +0200 Subject: [PATCH 05/11] Allow bot to attack mobs they need to kill / loot for quests up to 5 levels above their level --- src/strategy/values/GrindTargetValue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/values/GrindTargetValue.cpp b/src/strategy/values/GrindTargetValue.cpp index ae8fffdb..0be03904 100644 --- a/src/strategy/values/GrindTargetValue.cpp +++ b/src/strategy/values/GrindTargetValue.cpp @@ -160,7 +160,7 @@ bool GrindTargetValue::needForQuest(Unit* target) { QuestStatusData* questStatus = sTravelMgr->getQuestStatus(bot, questId); - if (questTemplate->GetQuestLevel() > bot->GetLevel()) + if (questTemplate->GetQuestLevel() > bot->GetLevel()+5) continue; for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) From 78832f106ee5800ab248827820bc16f5f1981d2b Mon Sep 17 00:00:00 2001 From: Revision Date: Sun, 28 Jul 2024 02:43:22 +0200 Subject: [PATCH 06/11] Add bots to transports Add bots to transports they're on so they actually move with it. --- src/strategy/actions/MovementActions.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index ed002f53..7ae2f99f 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -849,6 +849,21 @@ void MovementAction::UpdateMovementState() if (bot->IsFlying()) bot->UpdateSpeed(MOVE_FLIGHT, true); + + Transport* newTransport = bot->GetMap()->GetTransportForPos(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot); + if (newTransport != bot->GetTransport()) + { + LOG_DEBUG("playerbots", "Bot {} is on a transport", IsMovingAllowed()); + + if (bot->GetTransport()) + bot->GetTransport()->RemovePassenger(bot, true); + + if (newTransport) + newTransport->AddPassenger(bot, true); + + bot->StopMovingOnCurrentPos(); + } + // Temporary speed increase in group //if (botAI->HasRealPlayerMaster()) //bot->SetSpeedRate(MOVE_RUN, 1.1f); From 75475e398685ef95a700d3a2084d082986df99eb Mon Sep 17 00:00:00 2001 From: Revision Date: Sun, 28 Jul 2024 02:57:46 +0200 Subject: [PATCH 07/11] Fix debug message --- src/strategy/actions/MovementActions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 7ae2f99f..dae03815 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -853,7 +853,7 @@ void MovementAction::UpdateMovementState() Transport* newTransport = bot->GetMap()->GetTransportForPos(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot); if (newTransport != bot->GetTransport()) { - LOG_DEBUG("playerbots", "Bot {} is on a transport", IsMovingAllowed()); + LOG_DEBUG("playerbots", "Bot {} is on a transport", bot->GetName()); if (bot->GetTransport()) bot->GetTransport()->RemovePassenger(bot, true); From 5d64cd04dcbb78c96bdf062c420e5ab1ec3a7dd9 Mon Sep 17 00:00:00 2001 From: Revision Date: Sun, 28 Jul 2024 04:00:51 +0200 Subject: [PATCH 08/11] Fix bots looting quest objects --- src/LootObjectStack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LootObjectStack.cpp b/src/LootObjectStack.cpp index acda2e2f..5b792865 100644 --- a/src/LootObjectStack.cpp +++ b/src/LootObjectStack.cpp @@ -96,7 +96,7 @@ void LootObject::Refresh(Player* bot, ObjectGuid lootGUID) if (IsNeededForQuest(bot, itemId)) { - this->guid = guid; + this->guid = lootGUID; return; } isQuestItemOnly |= itemId > 0; From 318dbb9975f5c522a4b6fc0c1322f5df3d40c41c Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 28 Jul 2024 10:43:20 +0800 Subject: [PATCH 09/11] [Command] Command filter for multiple players --- src/PlayerbotAI.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 6a4c7b3f..fa59ff11 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -350,7 +350,7 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal std::string const command = holder.GetCommand(); Player* owner = holder.GetOwner(); - if (owner == master && !helper.ParseChatCommand(command, owner) && holder.GetType() == CHAT_MSG_WHISPER) + if (!helper.ParseChatCommand(command, owner) && holder.GetType() == CHAT_MSG_WHISPER) { // To prevent spam caused by WIM if (!(command.rfind("WIM", 0) == 0) && @@ -625,10 +625,15 @@ void PlayerbotAI::HandleCommand(uint32 type, std::string const text, Player* fro return; } - if (!IsAllowedCommand(filtered) && !GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer)) + if (!IsAllowedCommand(filtered) && + (master != fromPlayer || !GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer))) return; - if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos && filtered.find("award") == std::string::npos) + if (!IsAllowedCommand(filtered) && master != fromPlayer) + return; + + if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos && + filtered.find("award") == std::string::npos) { ChatCommandHolder cmd("warning", fromPlayer, type); chatCommands.push(cmd); From fd74ae8af782aab0086a485cb7883b62b766ae82 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 28 Jul 2024 11:02:16 +0800 Subject: [PATCH 10/11] [Command] Fix revive condition for summon --- src/strategy/actions/UseMeetingStoneAction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strategy/actions/UseMeetingStoneAction.cpp b/src/strategy/actions/UseMeetingStoneAction.cpp index 2bc87266..5380d6f9 100644 --- a/src/strategy/actions/UseMeetingStoneAction.cpp +++ b/src/strategy/actions/UseMeetingStoneAction.cpp @@ -206,7 +206,7 @@ bool SummonAction::Teleport(Player* summoner, Player* player) return false; } - bool revive = sPlayerbotAIConfig->reviveBotWhenSummoned == 2 || (sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !master->IsInCombat()); + bool revive = sPlayerbotAIConfig->reviveBotWhenSummoned == 2 || (sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !master->IsInCombat() && master->IsAlive()); if (bot->isDead() && revive) { bot->ResurrectPlayer(1.0f, false); From b75dcb67ff04eb34e45c6f4797815d6365f74e05 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 28 Jul 2024 11:05:21 +0800 Subject: [PATCH 11/11] [CI] Fix bad CI --- .github/workflows/core_build.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/core_build.yml b/.github/workflows/core_build.yml index 45de9b47..4711f923 100644 --- a/.github/workflows/core_build.yml +++ b/.github/workflows/core_build.yml @@ -62,32 +62,12 @@ jobs: - name: Install Requirements run: sudo apt-get update && sudo apt-get install ccache git cmake make gcc g++ clang libmysqlclient-dev libssl-dev libbz2-dev libreadline-dev libncurses-dev mysql-server libboost-all-dev - - name: setup ccache - shell: bash - env: - CCACHE_DIR: $GITHUB_WORKSPACE/var/ccache - run: | - cat <> $GITHUB_ENV - CCACHE_DIR=${{ env.CCACHE_DIR }} - CCACHE_MAXSIZE=1000MB - CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_mtime - CCACHE_CPP2=true - CCACHE_COMPRESS=1 - CCACHE_COMPRESSLEVEL=9 - CCACHE_COMPILERCHECK=content - CCACHE_LOGFILE=$CCACHE_DIR/cache.debug - CC=${{ inputs.CC }} - CXX=${{ inputs.CXX }} - EOF - - name: Configure CMake run: > cmake -B ${{ steps.strings.outputs.build-output-dir }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" - -DCMAKE_C_COMPILER_LAUNCHER="ccache" -S ${{ github.workspace }} - name: Build