mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
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.
This commit is contained in:
@@ -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<uint32>();
|
||||
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<uint32> mounts;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 spellId = fields[0].Get<uint32>();
|
||||
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<int32, std::vector<uint32>>& spells = allSpells[masterMountType];
|
||||
if (hasSwiftMount)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user