From 11654425058bcddad0036cc96785556720ceaab5 Mon Sep 17 00:00:00 2001 From: Bobblybook Date: Sat, 19 Oct 2024 18:16:44 +1100 Subject: [PATCH 1/3] Winged Steed of the Ebon Blade northrend fix Winged Steed of the Ebon Blade gets incorrectly categorised as a ground mount, causes issues and bots will not be able to ground mount if they have this mount in the account spellbook. There may by other scaling mounts that have the same issue, either we blacklist them all or figure out a way to correctly read them as flyers. --- src/strategy/actions/CheckMountStateAction.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index ce223d16..0300827b 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -239,9 +239,16 @@ bool CheckMountStateAction::Mount() // continue; uint32 index = (spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED || - spellInfo->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) - ? 1 - : 0; + spellInfo->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED || + // Winged Steed of the Ebon Blade + // This mount is meant to autoscale from a 150% flyer + // up to a 280% as you train your flying skill up. + // This incorrectly gets categorised as a ground mount, force this to flyer only. + // TODO: Add other scaling mounts here if they have the same issue, or adjust above + // checks so that they are all correctly detected. + spellInfo->Id == 54729) + ? 1 // Flying Mount + : 0; // Ground Mount if (index == 0 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 59) From 312c661311f6a4d25feb386323509fa7889e0596 Mon Sep 17 00:00:00 2001 From: Bobblybook Date: Sat, 19 Oct 2024 22:40:26 +1100 Subject: [PATCH 2/3] Preferred mount selection for bots Added a new table to store user-specified mount ids. Can specify flying and ground mounts for a character which will prioritise that mount. If multiple entries, a random entry will be selected from that list. Currently no way to add entries other than manual DB editing, but can be developed into a whisper command pretty easily. This should gracefully fail (if no entries exist for the character, or the db table does not exist) and fallback to the default random selection as usual. --- .../base/playerbots_preferred_mounts.sql | 10 ++++++ .../actions/CheckMountStateAction.cpp | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 sql/playerbots/base/playerbots_preferred_mounts.sql diff --git a/sql/playerbots/base/playerbots_preferred_mounts.sql b/sql/playerbots/base/playerbots_preferred_mounts.sql new file mode 100644 index 00000000..6d904fb3 --- /dev/null +++ b/sql/playerbots/base/playerbots_preferred_mounts.sql @@ -0,0 +1,10 @@ +DROP TABLE IF EXISTS `playerbots_preferred_mounts`; +CREATE TABLE `playerbots_preferred_mounts` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `guid` INT(11) NOT NULL, + `type` TINYINT(3) NOT NULL COMMENT '0: Ground, 1: Flying', + `spellid` INT(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `guid` (`guid`), + KEY `type` (`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index 0300827b..7ae52f74 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -270,6 +270,42 @@ bool CheckMountStateAction::Mount() : 0; } + // Check for preferred mounts table in db + QueryResult checkTable = PlayerbotsDatabase.Query( + "SELECT EXISTS(SELECT * FROM information_schema.tables WHERE table_schema = 'acore_playerbots' AND table_name = 'playerbots_preferred_mounts')"); + + if (checkTable) + { + uint32 tableExists = checkTable->Fetch()[0].Get(); + if (tableExists == 1) + { + // Check for preferred mount entry + QueryResult result = PlayerbotsDatabase.Query( + "SELECT spellid FROM playerbots_preferred_mounts WHERE guid = {} AND type = {}", + bot->GetGUID().GetCounter(), masterMountType); + + if (result) + { + std::vector mounts; + do + { + Field* fields = result->Fetch(); + uint32 spellId = fields[0].Get(); + mounts.push_back(spellId); + } while (result->NextRow()); + + uint32 index = urand(0, mounts.size() - 1); + // Validate spell ID + if (index < mounts.size() && sSpellMgr->GetSpellInfo(mounts[index])) + { + // TODO: May want to do checks for 'bot riding skill > skill required to ride the mount' + return botAI->CastSpell(mounts[index], bot); + } + } + } + } + + // No preferred mount found (or invalid), continue with random mount selection std::map>& spells = allSpells[masterMountType]; if (hasSwiftMount) { From eb5dd450cdcf3de57805f221d95faf8d4d8d5f89 Mon Sep 17 00:00:00 2001 From: Bobblybook Date: Sat, 19 Oct 2024 22:42:21 +1100 Subject: [PATCH 3/3] Revert "Preferred mount selection for bots" This reverts commit 312c661311f6a4d25feb386323509fa7889e0596. --- .../base/playerbots_preferred_mounts.sql | 10 ------ .../actions/CheckMountStateAction.cpp | 36 ------------------- 2 files changed, 46 deletions(-) delete mode 100644 sql/playerbots/base/playerbots_preferred_mounts.sql diff --git a/sql/playerbots/base/playerbots_preferred_mounts.sql b/sql/playerbots/base/playerbots_preferred_mounts.sql deleted file mode 100644 index 6d904fb3..00000000 --- a/sql/playerbots/base/playerbots_preferred_mounts.sql +++ /dev/null @@ -1,10 +0,0 @@ -DROP TABLE IF EXISTS `playerbots_preferred_mounts`; -CREATE TABLE `playerbots_preferred_mounts` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `guid` INT(11) NOT NULL, - `type` TINYINT(3) NOT NULL COMMENT '0: Ground, 1: Flying', - `spellid` INT(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `guid` (`guid`), - KEY `type` (`type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index 7ae52f74..0300827b 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -270,42 +270,6 @@ bool CheckMountStateAction::Mount() : 0; } - // Check for preferred mounts table in db - QueryResult checkTable = PlayerbotsDatabase.Query( - "SELECT EXISTS(SELECT * FROM information_schema.tables WHERE table_schema = 'acore_playerbots' AND table_name = 'playerbots_preferred_mounts')"); - - if (checkTable) - { - uint32 tableExists = checkTable->Fetch()[0].Get(); - if (tableExists == 1) - { - // Check for preferred mount entry - QueryResult result = PlayerbotsDatabase.Query( - "SELECT spellid FROM playerbots_preferred_mounts WHERE guid = {} AND type = {}", - bot->GetGUID().GetCounter(), masterMountType); - - if (result) - { - std::vector mounts; - do - { - Field* fields = result->Fetch(); - uint32 spellId = fields[0].Get(); - mounts.push_back(spellId); - } while (result->NextRow()); - - uint32 index = urand(0, mounts.size() - 1); - // Validate spell ID - if (index < mounts.size() && sSpellMgr->GetSpellInfo(mounts[index])) - { - // TODO: May want to do checks for 'bot riding skill > skill required to ride the mount' - return botAI->CastSpell(mounts[index], bot); - } - } - } - } - - // No preferred mount found (or invalid), continue with random mount selection std::map>& spells = allSpells[masterMountType]; if (hasSwiftMount) {