MCPcopy Create free account
hub / github.com/EQEmu/EQEmu / LoadBotSettings

Method LoadBotSettings

zone/bot_database.cpp:2256–2318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2254}
2255
2256bool BotDatabase::LoadBotSettings(Mob* m)
2257{
2258 if (!m) {
2259 return false;
2260 }
2261
2262 if (!m->IsOfClientBot()) {
2263 return false;
2264 }
2265
2266 uint32 mob_id = (m->IsClient() ? m->CastToClient()->CharacterID() : m->CastToBot()->GetBotID());
2267 uint8 stance_id = (m->IsBot() ? m->CastToBot()->GetBotStance() : 0);
2268
2269 std::string query = "";
2270
2271 if (m->IsClient()) {
2272 query = fmt::format("`character_id` = {} AND `stance` = {}", mob_id, stance_id);
2273 }
2274 else {
2275 query = fmt::format("`bot_id` = {} AND `stance` = {}", mob_id, stance_id);
2276 }
2277
2278 if (stance_id == Stance::Passive) {
2279 LogBotSettings("{} is currently set to {} [#{}]. No saving or loading required.", m->GetCleanName(), Stance::GetName(Stance::Passive), Stance::Passive);
2280 return true;
2281 }
2282
2283 const auto& l = BotSettingsRepository::GetWhere(database, query);
2284
2285 if (l.empty()) {
2286 return true;
2287 }
2288
2289 for (const auto& e : l) {
2290 if (e.setting_type == BotSettingCategories::BaseSetting) {
2291 LogBotSettings("[{}] says, 'Loading {} [{}] - setting to [{}].",
2292 m->GetCleanName(),
2293 Bot::GetBotSettingCategoryName(e.setting_type),
2294 e.setting_type,
2295 e.value
2296 );
2297 }
2298 else {
2299 LogBotSettings("[{}] says, 'Loading {} [{}], {} [{}] - setting to [{}].",
2300 m->GetCleanName(),
2301 Bot::GetBotSpellCategoryShortName(e.setting_type),
2302 e.setting_type,
2303 Bot::GetSpellTypeNameByID(e.setting_id),
2304 e.setting_id,
2305 e.value
2306 );
2307 }
2308
2309 if (m->IsClient()) {
2310 m->CastToClient()->SetBotSetting(e.setting_type, e.setting_id, e.value);
2311 }
2312 else {
2313 m->CastToBot()->SetBotSetting(e.setting_type, e.setting_id, e.value);

Callers 3

BotMethod · 0.80
bot_command_stanceFunction · 0.80

Calls 12

GetNameFunction · 0.85
GetBotStanceMethod · 0.80
IsOfClientBotMethod · 0.45
IsClientMethod · 0.45
CharacterIDMethod · 0.45
CastToClientMethod · 0.45
GetBotIDMethod · 0.45
CastToBotMethod · 0.45
IsBotMethod · 0.45
GetCleanNameMethod · 0.45
emptyMethod · 0.45
SetBotSettingMethod · 0.45

Tested by

no test coverage detected