mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Quest API] Add Bot Methods to Perl/Lua (#4113)
* [Quest API] Add Bot Methods to Perl/Lua # Perl - Add `quest::GetBotClassByID(bot_id)`. - Add `quest::GetBotGenderByID(bot_id)`. - Add `quest::GetBotIDsByCharacterID(character_id)`. - Add `quest::GetBotIDsByCharacterID(character_id, class_id)`. - Add `quest::GetBotLevelByID(bot_id)`. - Add `quest::GetBotNameByID(bot_id)`. - Add `quest::GetBotRaceByID(bot_id)`. # Lua - Add `eq.get_bot_class_by_id(bot_id)`. - Add `eq.get_bot_gender_by_id(bot_id)`. - Add `eq.get_bot_ids_by_character_id(character_id)`. - Add `eq.get_bot_ids_by_character_id(character_id, class_id)`. - Add `eq.get_bot_level_by_id(bot_id)`. - Add `eq.get_bot_name_by_id(bot_id)`. - Add `eq.get_bot_race_by_id(bot_id)`. # Notes - Allows operators to get a list of a player's bot IDs, get a bot's class, gender, level, name, and race. * Update bot_database.cpp
This commit is contained in:
@@ -2318,3 +2318,65 @@ bool BotDatabase::SaveBotCasterRange(const uint32 bot_id, const uint32 bot_caste
|
||||
|
||||
return BotDataRepository::UpdateOne(database, e);
|
||||
}
|
||||
|
||||
const uint8 BotDatabase::GetBotClassByID(const uint32 bot_id)
|
||||
{
|
||||
const auto& e = BotDataRepository::FindOne(database, bot_id);
|
||||
|
||||
return e.bot_id ? e.class_ : Class::None;
|
||||
}
|
||||
|
||||
const uint8 BotDatabase::GetBotGenderByID(const uint32 bot_id)
|
||||
{
|
||||
const auto& e = BotDataRepository::FindOne(database, bot_id);
|
||||
|
||||
return e.bot_id ? e.gender : Gender::Neuter;
|
||||
}
|
||||
|
||||
std::vector<uint32> BotDatabase::GetBotIDsByCharacterID(const uint32 character_id, uint8 class_id)
|
||||
{
|
||||
std::vector<uint32> v;
|
||||
|
||||
const auto& l = BotDataRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`owner_id` = {}{}",
|
||||
character_id,
|
||||
(
|
||||
class_id ?
|
||||
fmt::format(
|
||||
" AND `class` = {}",
|
||||
class_id
|
||||
) :
|
||||
""
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
for (const auto& e : l) {
|
||||
v.push_back(e.bot_id);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
const uint8 BotDatabase::GetBotLevelByID(const uint32 bot_id)
|
||||
{
|
||||
const auto& e = BotDataRepository::FindOne(database, bot_id);
|
||||
|
||||
return e.bot_id ? e.level : 0;
|
||||
}
|
||||
|
||||
const std::string& BotDatabase::GetBotNameByID(const uint32 bot_id)
|
||||
{
|
||||
const auto& e = BotDataRepository::FindOne(database, bot_id);
|
||||
|
||||
return e.bot_id ? e.name : std::string();
|
||||
}
|
||||
|
||||
const uint16 BotDatabase::GetBotRaceByID(const uint32 bot_id)
|
||||
{
|
||||
const auto& e = BotDataRepository::FindOne(database, bot_id);
|
||||
|
||||
return e.bot_id ? e.race : Race::Doug;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user